Hello, my name is Flysen and I will make an anti cheat system. I’m trying to make an undeletable script but with my option, the server lag. Do you know if I can clone script with a while without server bug?
local settingsModule = require(script.Parent.Settings)
local blacklistedPeople = settingsModule.blacklistedPeople
-- Do not edit this part --
local plrsInGame = game.Players:GetChildren()
local function detectChar(plr, char)
game.ServerStorage["Anti-Cheat (By Flysen)"]:Clone().Parent = plr.Character
while wait(2) do
pcall(function()
plr.Character["Anti-Cheat (By Flysen)"]:Destroy()
game.ServerStorage["Anti-Cheat (By Flysen)"]:Clone().Parent = plr.Character
end)
end
end
game.Players.PlayerAdded:Connect(function(plr)
print("New player")
if not table.find(blacklistedPeople, plr.UserId) then
table.insert(plrsInGame, 1, plr)
local char = plr.Character or plr.CharacterAdded:Wait()
detectChar(plr, char)
plr.CharacterAdded:Connect(function(char)
detectChar(plr, char)
end)
end
end)
It doesn’t seem very likely you can make an undeletable script, as you can just delete the server side script that clones it. (assuming its an anti cheat for free models). For client side, as @NinjaFurfante07 said, if the script gets deleted on the client side, it doesn’t replicate to the server. Use a remoteevent or something, but that just creates more lag, and you can easily just delete that script as well.
But you do it only once, when the player joins. Also you should clone infinite times the script and you cannot do if :FindFirstChild to avoid this as if the script gets deleted client side it doesv;t get replicated to the server. In short, no offence, you are doing an inutil work
They will not be able to remove the script that gives the anticheat but the anticheat can be deleted. There are lots of posts asking the same thing and everyone received this answer
You can not make a script “undeletable” but you can check if it’s deleted or disabled and do something…
while true do --looping it every 5 seconds, so it's not bad on performance
wait(5)
local script = game:WaitForChild("ScriptName") -- looking for script a defining it
if script == nil or script.Disabled == true then --looking if its disabled
wait(1.5) -- wait 1.5 seconds before taking action just because
game.Players.LocalPlayer:kick("Script disabling / deleting detected") -- this is our action kicking the
player
game.Players.LocalPlayer.PlayerGui:Destroy() -- not only do we kick but we also destory all their player guis so if they are trying to use dex, or any other service to look at your scripts or steal them their service will be destoryed, this is just a small measure but won't help much against really experienced exploiters
end
end
end