Problem with gun

Hello! I’ve been trying to make a gun and I want to make it so the bullets are facing my mouse but in the correct way, I found a way to make it turn but not facing the way I want, does anyone have any solutions?

Use raycast instead of mouse. using mouse would allow the player to shoot behind them so make a raycast from the players head

local player = game.Players.LocalPlayer	
local Character = player.Character or player.CharacterAdded:Wait()

	local Range = 500

	game:GetService("RunService").RenderStepped:Connect(function()
		local ray = Ray.new(Character.Head.Position, Character.Head.CFrame.LookVector * Range)
		local hit = workspace:FindPartOnRay(ray)

		if hit then
             --- Code Here
		end
	end)

If the user is asking for a script to fix their gun, why would you give them somethign completely different to what they’ve asked for? Not to mention using that method is rather foolish, especially since certain shots will miss even though they should hit.

Also, you’re using the deprecated ray service.

PS: You’re also using RenderStepped which should only be reserved for vital services such as the camera.

1 Like

Well using raycast is better no matter what mouse can cause more bugs then fix