I made a very simple AntiNoclip script (Which you can find below), and I want ways to improve it. For example: When a player turns a corner do not mark false positives. Or when a vehicle or moving object / instance gets in between the last known player position, and their current position. I also want to know if this detects false positives.
– *Incomplete code used to be here! Now use the model below.
I think you should also re-cast from where the ray stopped, but with the hit part in the ignore list. Keep doing this until the ray reaches the current position of the player.
Is your character in workspace? Make sure the character is actually parented under workspace first before doing that check. This might be because the character has been created but not parented yet.
(On second thought this doesn’t make too much sense because server-side scripts don’t run when parented to nil…)
Nothing is going to be testable until you fix this:
local RY = Ray.new(LastVec, root.Position)
That’s a ray from the character’s last position, but the ray direction and length are those of the vector from the world origin to the current position. You probably meant:
local RY = Ray.new(LastVec, root.Position - LastVec)
iirc Raycasting is very expensive to do and running it every frame doesn’t seem like a very good idea for game performance but since you asked here is a script that should work.
local runService = game:GetService("RunService")
local event;
local loopConnection;
-- // the reason I do this is because the server does not have a 'RenderStepped' event (and you did not specify if your code was being on the client or server, i have no idea why it would be on the client though but whatever the case)
if runService:IsServer() then
event = runService.Stepped
elseif runService:IsClient() then
event = runService.RenderStepped;
end
loopConnection = event:connect(function()
-- // your script here
end)
I figured it was server sided lol.
I’ve never really done this type of thing before, so I really don’t know how long you should wait between each raycast. Experimenting with the delay is probably your best bet.
Also, no. Exploiter can delete objects but the deletion will not replicate to the server so it would have no effect on your scripts. (The FilteringEnabled property is basically useless now since Roblox forces it on every game regardless if the property is set to true or false)
One ray per character per frame is not significant. Just replace wait(1) with RunService.Heartbeat:wait(), or (better still) ditch the while loop and connect to the RunService.Heartbeat event.
Just rate limits; a proper debounce should be applied for sending that message right away once, just kick the player(which then disconnects the script) or both.
I’m not sure about false positives, a system like this is bound to have them. Over time, your system should get better as it is tuned to stop false positives but not let real problems slip through the cracks.