0

# This shooting script does not work at all, does not shoot?

This following script is supposed to instance a new part, and make it shoot towards the player but it dosent do that! Thanks for the help

local function Shoot()

local bullet = Instance.new("Part", workspace.Bullets.EnemyBullets)
bullet.Size = Vector3.new(0.3,0.3,0.3)
bullet.Material = "Neon"

bullet.CFrame = Enemy.Torso.CFrame * CFrame.new(0,0,-4)
bullet.CanCollide = false

local velocity = Instance.new("BodyVelocity", bullet)
velocity.MaxForce = Vector3.new(math.huge,math.huge,math.huge)
bullet.CFrame = CFrame.new(bullet.Position, game.Players.LocalPlayer.Character.HumanoidRootPart.Position)
velocity.Velocity = bullet.CFrame.lookVector * 500 + Vector3.new(math.random(-25,25),math.random(-25,25),0)

end

while wait(2) do

Shoot()

end

0
Is the script a LocalScript? Jac_00b 157 — 9d
0
yes it is. I've tried it in a server script and didn't change anything KoalaKo_XD 27 — 9d

0
Jac_00b 157
9 days ago
Edited 9 days ago

You said in the comments that this was in a LocalScript. LocalScripts are meant for things that only the client can see, so no other clients in the server will be able to see the bullet. However, it's not as easy as just switching it to a server script, as you referenced game.Players.LocalPlayer, which only LocalScripts can use.

Assuming that this script is in a Tool, then we can easily access the Character, as equipped tools are in the character model itself. If the script is under the Tool directly, then you can reference script.Parent.Parent to get the character. If it's in the handle, add an extra .Parent to compensate for it. (The new line below shows it as if it is under the Tool directly)

So, the script should be changed to a server script, and the new line 12 should be:

bullet.CFrame = CFrame.new(bullet.Position, script.Parent.Parent.HumanoidRootPart.Position)


Hope this helped.