I tried making this but it didnt work. It disappeared and came back but nothing happened when I clicked it.
My code:
script.Parent.ClickDetector.MouseClick:Connect(function(player) script.Parent.Transparency = 1 script.Parent.CanCollide = false script.Parent.ClickDetector:Destroy() wait(10) script.Parent.Transparency = 0 script.Parent.CanCollide = true local click = Instance.new("ClickDetector") click.Parent = script.Parent end)
Please help!
Rather than destroying the click detector, what I'd do is make it a variable and parent it elsewhere until you need to use it again.
local clickDetector = script.Parent.ClickDetector clickDetector.MouseClick:Connect(player) script.Parent.Transparency = 1 script.Parent.CanCollide = false clickDetector.Parent = game.ServerStorage wait(10) script.Parent.Transparency = 0 script.Parent.CanCollide = true clickDetector.Parent = script.Parent end)
Obviously you can parent it where ever you need but in hindsight I feel it's a lot easier than destroying it and then creating a new one.