Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

I made this code which destroys a click detector and then creates it. Am I right?

I made this code which destroys a Clickdetector in the scripts parent and then clones the Clickdetector but the destroying part works but not the cloning part to then create back the clickdetector.

My Code:

local click = script.Parent.ClickDetector --or wherever it is

click.MouseClick:Connect(function(player)
     script.Parent.ClickDetector:Destroy()
     wait(20)
     script.Parent.ClickDetector:Clone()
end)

Thank You and Help is Appreciated

6 comments

0

u cant clone smth that has been destroyed

0

bro i answered your last question an hour ago

1

jesus you have less than half a brain.

0

@gioni01 your code didnt work

0

You destroyed the clickdetector so you cannot clone something that is destroyed.

0

Why would you even want to do this?

2 answers

local click = script.Parent.ClickDetector --or wherever it is*
local Cloned = click:Clone()

click.MouseClick:Connect(function(player)
     Cloned.Parent = game.Workspace --This put the "Clone" of "click" in the Workspace
     click:Destroy()
     wait(20)
     Cloned.Parent = script.Parent
end)

I haven't try that script but it should work.

1 comment

0

i think it's better if he clone the button when clicked

local click = script.Parent.ClickDetector
	 
	click.MouseClick:Connect(function(player)
		        local ClickClone = click:Clone()
			ClickClone.Parent = game.ReplicatedStorage
			click:Destroy()

			wait(20)

			ClickClone.Parent = script.Parent
	end)

	-- Bingo Bongo.

This discussion is preserved as it was. New answers, comments, and votes are closed.