I know that this has been asked many times, but none of the solutions seem to work for me. I used a devforum article, but this broke the gun completely. this is the ray part of the script.

--//Hit detection


local SPREAD = 1000 -- set some value for it
	local spreadPosition = Vector3.new(
		hole.CFrame.p.Position.X + math.random(-SPREAD, SPREAD)/1000,
		hole.CFrame.p.Position.Y + math.random(-SPREAD, SPREAD)/1000,
		hole.CFrame.p.Position.Z + math.random(-SPREAD, SPREAD)/1000
	)
	--//Cast ray
	local ray = Ray.new(hole.CFrame.p, (mouse.hit.p - spreadPosition).unit * range.Value)
	local touch, position = workspace:FindPartOnRay(ray, player.Character, false, true)
	
	
	if touch then
		hitRemote:FireServer(touch)
	end
	shootRemote:FireServer()

the spread system above breaks the gun, so am I doing something wrong?

2 comments

0

Why are you doing this on the client? Do it on the server. The reason why is because exploiters can literally spam the raycast, and abuse the remote event. So use the raycast on the server, not on the client.

0

Alright, but that's for later. Will doing that fix the above? Or no.