I have made a Click Detector script but when I finish clicking and when it came back nothing worked why?
local Rock = game.Workspace.Rock local target = game.ReplicatedStorage.ClickDetector local TimesClicked = 0 local a = game.Workspace.Rock.ClickDetector.Script local Click = game.Workspace.Rock.ClickDetector script.Parent.mouseClick:Connect(function(Player) TimesClicked = TimesClicked +1 if TimesClicked == 3 and TimesClicked ~= nil then Player.leaderstats.SpacePieces.Value = Player.leaderstats.SpacePieces.Value +2 script.Parent.Parent.Transparency = 1 script.Parent.Parent.CanCollide = true a.Parent = game.Workspace.Rock Click:Destroy() wait(3) Rock.Transparency = 0 Rock.CanCollide = false local ClickDetector = target:Clone() ClickDetector.Parent = game.Workspace.Rock end end)
Please help!
Basically you want a rock to appear and disappear after 3 seconds when you click 3 buttons and give money? Give this a try, it is sample code and is not tested.
And by the way, destroying the object is not very useful, cloning is slightly hard, putting a click detector in a newly made rock probably won't work properly....
local rock = workspace.Rock -- get rock local Clicker = workspace.Rock.ClickDetector -- get detector local timesClicked = 0 Clicker.MouseClick:Connect(function(Person) timesClicked = timesClicked + 1 if timesClicked >= 3 then workspace.Rock.ClickDetector.Parent = game.ReplicatedStorage timesClicked = 0 Person.leaderstats.SpacePieces.Value = Person.leaderstats.SpacePieces.Value + 2 rock.Transparency = 1 rock.CanCollide = false wait(3) rock.CanCollide = true rock.Transparency = 0 workspace.Rock.ClickDetector.Parent = workspace.Rock end end
Since u set the rock already from the start, if you remove it and replicate it, the original rock is still stored in the variable "rock" and you won't be able to do much unless you use a loop. SO try it my way, thanks