So I have a script where a coin gives you one coin then destroys. Is there any way you can use something like a wait until function to do wait until part1 is destroyed then let the person be able to collect part2?
Ok, erm so what I'm going to say is gonna sound stupid in a way but it'll work.
So in order to do this you do:
while true do if game.Workspace:FindFirstChild("part1") == nil then game.Workspace.part2.Touched:connect(function() [put whatever code you wanted here] end) break end wait() end
I did this
while true do if game.Workspace:FindFirstChild("part1") == nil then game.Workspace.part2.Touched:connect(function() script.Parent.Touched:connect(function(part) if game.Players:findFirstChild(part.Parent.Name) then local plr = game.Players:findFirstChild(part.Parent.Name) plr.leaderstats.Coins.Value = plr.leaderstats.Coins.Value + 1 end end) local debounce = true script.Parent.Touched:connect(function(part) if debounce then debounce = false if game.Players:findFirstChild(part.Parent.Name) then local plr = game.Players:findFirstChild(part.Parent.Name) plr.leaderstats.Coins.Value = plr.leaderstats.Coins.Value +1 script.Parent:destroy() end end end) end) break end wait() end
I don't know how to fix it