So recently I’ve come up with a way to stop LocalSripts from being deleted by exploiters in-game. However, some of you may have thought of this solution too. If so, please give me advice on how to improve/what I should change in the following:
My idea is to have a LocalScript parented to a Script in ServerScriptService. The LocalScript will be the anti-exploit and the Script will clone the LocalScript into the necessary position in a loop.
I can’t seem to figure out a way around this if I were an exploiter since the LocalScripts are being cloned from a Script. But if you do fine a workaround, please tell me.
Code for the script:
local LocalScript = script.LocalScript -- LocalScript parented to this Script.
game.Players.PlayerAdded:Connect(function(Player)
while wait(10) do
local ClonedLocalScript = LocalScript:Clone()
ClonedLocalScript.Parent = Player.Character
ClonedLocalScript.Name = "AntiExploit"
ClonedLocalScript.Disabled = false
end
end)
Now for the LocalScript, we will also run in a check to see if there’s already a copy of the same LocalScript in the player’s character, where it gets parented to. If a copy is already there, the script deletes itself, and if it doesn’t, it kicks the player.
local Player = game.Players.LocalPlayer
local Character = Player.Character
if Character:FindFirstChild("AntiExploit") then
return script:Destroy()
else
Player:Kick("You deleted the AntiExploit.")
end
-- Detects WalkSpeed changes (simple for demonstration purposes)
Character.Humanoid:GetPropertyChangedSignal("WalkSpeed"):Connect(function(WalkSpeed)
if WalkSpeed ~= 16 then
Player:Kick("Your WalkSpeed changed.")
end
end)
Any feedback is appreciated.