THE PROBLEM: The guns projectile does not go where the mouse cursor is looking, I have researched this for a good few hours and have no clue what to do, if someone could point me in the right direction. (I don't need the gun to rotate with the player I just want the projectile to shoot from the mouses location)
HOW THE GUN WORKS It takes a projectile from a folder in workspace and clones it, the projectile has code to move itself forward and also damage players on impact. currently I am setting the clones position to the position of a part attached to the gun tool currently for testing purposes.
SCRIPT
Gun firing script:
local tool = script.Parent local handle = tool:WaitForChild('Handle') local FirePort = script.Parent.Handle.Real_Fire_Part local ammo = game.ReplicatedStorage.Hyper_Ammo_Sniper tool.Equipped:Connect(function() tool.Equip.Playing = true wait(2) tool.Equip.Playing = false end) tool.Activated:Connect(function() if ammo.Value > 0 then print("phase1") local bullet = game.Workspace.Projectiles.Hyper_Sniper_bullet:Clone() bullet.Parent = game.Workspace bullet.Anchored = true bullet.Position = script.Parent.Handle.Real_Fire_Part.Position bullet.Orientation = FirePort.Orientation tool.Fire.Playing = true ammo.Value = ammo.Value - 1 print("phase2") end end)
Please help i've got no clue what to do here.
I'm going to assume you want to create a weapon that fires projectiles instead of raycasting, which I personally don't recommend, but to each their own.
Your code seems good. The reason the bullet does not go forward is because your firepart is likely facing the wrong way. Try changing the direction of your firepart, and seeing if that fixes it.