So I have placed a local script inside a screen gui with the field 'Reset on Spawn' set to false. The script gets the name of the Local Player, then sets its Parent to nil. It works fine, but what I want to know is:
Would hackers and exploiters still be able to delete a 'nil instance'? Is this a sure-fire way to prevent speed hackers?
local plr = game:GetService("Players").LocalPlayer while true do wait() script.Parent = nil --Setting the parent to nil so hackers cannot delete it local character = plr.Character local human = character:FindFirstChildOfClass("Humanoid") if human then if human.WalkSpeed > 16 then plr:Kick() end end end
I think the safest way is to make a script in the ServerScriptService
game.Players.PlayerAdded:Connect(function(plr) repeat wait() until plr.Character while true do wait() if plr.Character.Humanoid.WalkSpeed > 16 then plr:Kick() end end end)
Putting the script in a localscript is not very safe.. because it could simply be deleted; so put this in a Server script, somewhere in ServerScriptService..
try to hook every statement with an event to reduce memory consumption, the bigger memory consumption, the laggy your game is..
local maxSpeed = 16 -- change to the absolutely max speed in game game.Players.PlayerAdded:Connect(function(player) player.CharacterAdded:Connect(function(char) local humanoid = char:WaitForChild("Humanoid"); if humanoid then humanoid.Changed:Connect(function() if humanoid.WalkSpeed > maxSpeed then player:Kick("You just can't win without cheating, can you? /:") end end) end end) end)