feranoJoin Date: 2008-11-23 Post Count: 5094 |
So this isn't necessarily a gun script, it is a script that shoots out arrows from the weapon. It is not complete so some of the values are unused, however why do the arrows that the tool shoots come out slowly and why do they come out on weird angles? How do I fix this? Here is the script (it is a local script):
Player = game.Players.LocalPlayer
Gun = script.Parent
--EDITABLES--
Ammo = 100
RechargeTime = 1
HeadDamage = 100
TorsoDamage = 50
LimbDamage = 30
-------------
mouse = Player:GetMouse()
enabled = true
function Shoot()
if Ammo > 0 and enabled == true then
Ammo = Ammo -1
wait(RechargeTime) -- INSERT ANIMATION CODE HERE
local Bullet = Instance.new("Part", workspace)
Gun.GripPos = Vector3.new(0, -0.35, 0.4)
game.Debris: AddItem(Bullet, 3)
Bullet.Shape = "Cylinder"
Bullet.Size = Vector3.new(0.1,0.1,0.1)
Bullet.TopSurface = "Smooth"
Bullet.BottomSurface = "Smooth"
Bullet.BrickColor = BrickColor.new("New yeller")
Bullet.CanCollide = true
Bullet.CFrame = Gun.Handle.CFrame
Bullet.CFrame = CFrame.new(Bullet.Position, mouse.Hit.p)
Bullet.Name = "Bullet"
local BM = Instance.new("SpecialMesh", Bullet)
BM.MeshType = ("FileMesh")
BM.MeshId = ("http://www.roblox.com/asset/?id=15887356")
BM.TextureId = ("http://www.roblox.com/asset/?id=15886781")
BM.Scale = Vector3.new(-2, 2, -4.5)
local v = Instance.new("BodyVelocity",Bullet)
v.velocity = Bullet.CFrame.lookVector * 60
v.maxForce = Vector3.new (100,150,10)
local c = Instance.new("BodyForce", Bullet)
c.force = Vector3.new(0,150,0)
local FireSound = Instance.new("Sound", Bullet)
FireSound.SoundId = "http://www.roblox.com/asset/?id=16211030"
local RP = math.random(60,80)
RP = RP/10
FireSound.Pitch = RP
local RV = math.random(70, 90)
RV = RV/10
FireSound.Volume = RV
FireSound:Play()
game.Debris:AddItem(FireSound, 2)
Gun.GripPos = Vector3.new (0, -0.6, 0.6)
wait(RechargeTime)
end
end
Gun.Activated:connect(Shoot)
|
|
feranoJoin Date: 2008-11-23 Post Count: 5094 |
Bump |
|
feranoJoin Date: 2008-11-23 Post Count: 5094 |
Bump 2 |
|
feranoJoin Date: 2008-11-23 Post Count: 5094 |
Bump3 |
|
feranoJoin Date: 2008-11-23 Post Count: 5094 |
Bump4 |
|
Roblok1Join Date: 2011-07-27 Post Count: 2019 |
first, CFrame the bolt to the handle. then CFrame it's direction like this:
bolt.CFrame = bolt.CFrame*CFrame.new(bolt.CFrame, tool.Humanoid.Target)
next insert a bodyVelocity and set its velocity like this:
bodyVelocity.velocity = bolt.CFrame.lookvector*200 -- the speed is in SPS (studs per second)
then it should work fine
|
|
Roblok1Join Date: 2011-07-27 Post Count: 2019 |
oops, imn the first example, i meant to say this: Tool.Parent.Humanoid.Target
|
|
Roblok1Join Date: 2011-07-27 Post Count: 2019 |
one other thing, for what you're doing can be done in a fraction of the code.
|
|
feranoJoin Date: 2008-11-23 Post Count: 5094 |
How can it be done in a fraction of the code? |
|
feranoJoin Date: 2008-11-23 Post Count: 5094 |
How can I make this more efficient but doing the same thing, but working better. |
|