I made a gun that uses ray casting from watching a few videos I found online. The last argument to the ray is its max distance however, no matter what value I plug into this the bullet travels to wherever I clicked and doesn't stop before it. Can anyone explain to me how the max distance works? For reference, here's the script that I'm talking about:
--serverscriptservice local remote = game.ReplicatedStorage:WaitForChild("events"):WaitForChild("shotgunShoot") remote.OnServerEvent:connect(function(player, barrelPos, mousePos) local ray = Ray.new(barrelPos, (barrelPos - mousePos).unit * 100) --start, travel from, max distance local part, position = game.Workspace:FindPartOnRay(ray, player.Character, false, true) --cant hit themself, false is smooth terrain, true ignores water local distance = (barrelPos - mousePos).magnitude remote:FireAllClients(player, part, position, distance, barrelPos) end)