How to make a script that re-enable itself and appear when destroyed

im trying to make a system where it checks for clones in buttons in the player’s gui and destroys that clone when it sees one, but im worried that exploiters will destroy or disable the script and then they can clone the buttons,

so how can i make a system where when the script gets disabled it enables itself, and if it gets destroyed it appears back

any help will be appreciated

btw i have seen a similar topic on the dev forum and the answer was:

task.spawn(function()
	
	local clone = script:Clone() 
	local old_parent = script.Parent

	while task.wait(.1) do 
		if not script.Parent then
			local new = clone:Clone()
			new.Parent = old_parent 
			break
		elseif script.Disabled then 
			script.Disabled = false 
			break
		end
	end
end)

but for some reason it is not working at all.

Stopping the buttons from cloning probably wont stop the exploiter

If the buttons run some code when hit, they could just run that code without using the button

3 Likes

then what do you reccomend because i have a building system, where if the player presses a button it makes a transparent model follow the player mouse until he clicks and places it in the server, i cant make it server sided because i want it to be only seen by the player who clicked it

Why does it matter if the exploiter can see transparent models on their side?

If you want to stop them from building illegally then you can do checks on the serverside when they place something

1 Like

thanks for the suggestion, and i will do that but i still have the problem of cloning, because it messes with the entire scripts and glitches the game

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.