Can I make an undeletable script?

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)

This won’t work as the script will be deleted client side and the server will not detect it

yeah it’s why i clone new script and i delete but my server lag with this method

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.

1 Like

You can’t delete a script if he is server side

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

No, it’s not for only once because when a character is added, this start the function again

So it will give the script again when they die but this is a work that will not result in anything helpfull. Not to be rude but this is the reality.

If you don’t believe me you can search other answers in other topics, you will find the same…

My friend can use this method and it work

Sorry, this is my answer, I cannot say something that I don’t know or that doesn’t work.

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

Try this.