Hi, I’m trying to make a gun for a game. I’m trying to figure out how to stop the bullet from the gun from dropping down, and make it go where the mouse is at. Since I have no idea how I would do that, I looked at youtube tutorials as well as messing around with the script. I have tried and have not found a way to get it to work.
I am using a local script
local Gui = script.Parent:WaitForChild("ScreenGui")
local MaxAmmo = 4
local Ammo = 4
local WaitTime = 1
local StoredAmmo = 3
local ShootPart = script.Parent.ShootPart
script.Parent.Parent.Equipped:Connect(function(Mouse)
animation = game.Players.LocalPlayer.Character.Humanoid:LoadAnimation(script.Parent.Animation)
GuiClone = Gui:Clone()
GuiClone.Parent = game:GetService("Players").LocalPlayer.PlayerGui
animation:Play()
animation.Looped = true
end)
script.Parent.Parent.Activated:Connect(function(Mouse)
animation2 = game.Players.LocalPlayer.Character.Humanoid:LoadAnimation(script.Parent.Animation2)
GuiClone.Frame.TextLabel.Text = Ammo.."|"..StoredAmmo
GuiClone.Enabled = true
script.Parent.Sound:Play()
ammoCheck()
Ammo = Ammo - 1
shoot()
animation2:Play()
wait(WaitTime)
end)
script.Parent.Parent.Unequipped:Connect(function()
animation:Stop()
animation.Looped = false
GuiClone.Enabled = false
end)
function reload()
StoredAmmo = StoredAmmo - 1
Ammo = 4
if StoredAmmo < 1 then
GuiClone.Frame.TextLabel.Text = "No more ammo"
wait(1.5)
animation:Stop()
animation2:Stop()
GuiClone:Destroy()
script.Parent.Parent:Destroy()
end
end
function ammoCheck()
if Ammo < 1 then
reload()
end
end
function shoot()
local Bullet = Instance.new("Part", workspace)
Bullet.Size = Vector3.new(0.43, 0.13, 0.23)
Bullet.BrickColor = BrickColor.new("New Yeller")
Bullet.Material = Enum.Material.Neon
Bullet.Position = ShootPart.Position
local Force = Instance.new("BodyForce")
for count =1,10 do
wait()
Bullet.CFrame = Bullet.CFrame + Vector3.new(Force)
end
end
Right now I was just trying to get the bullet to move where the cursor is.