I’m currently trying to make something very simple.
I want a gun to shoot a projectile where its looking.
The issue is that the projectile isn’t going the way I want it to shoot.
I first used BodyVelocity for this, but then thought that maybe CFrame would be better.
local Mouse = game.Players.LocalPlayer:GetMouse()
while wait() do
if script.Parent.Move.Value == true then
script.Parent.CFrame = CFrame.new(script.Parent.Position - Mouse.Hit.Position)
end
end
This doesn’t seem to be working.
I’m using a server script in the bullet. So I tried using events to get the mouse but that didn’t seem to work “[13:29:10.525 - Workspace.Gun.ServerGun:12: attempt to index nil with ‘Hit’]”. Also, I think I’m going to start using BodyVelocity since someone said in my Discord server that CFrame is rather laggy. Might change my mind later though.
You need to send “mouse.Hit” to the server everytime player presses mouse button, so it would update. If you just send mouse to server then it can’t get mouse.Hit since you didn’t sent it it’s Hit value, and since mouse doesn’t exist in server you sending nil to the server. Also if you don’t update mouse.Hit everytime player pressed mouse button then it will be stuck in one direction like you showed in the video. Hope you understood what I said just now.
You are making the bullet go to where it’s facing, you didn’t align the rotation for it to shoot through, you could try the guy’s script above this post.
So, shortly after my dumb question I did some research and “Speed” meant how many studs per second the part would be travelling. I tried your solution out and it didn’t work, this was because of a stupid mistake I made! I accidentally forgot to parent the bodyvelocity to the bullet. Thank you!