Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

How can I make coins respawn in my game?

Asked by 5 years ago

I am trying to make a coin system in my game. It's working except that I just want the coins to respawn. What can I add to this script to make the coins respawn after a certain time limit?

local db = true
script.Parent.Touched:connect(function(hit)
    if hit.Parent:FindFirstChild("Humanoid") ~= nil then
        if db == true then
            db = false
            script.Parent.Transparency = 1
            local player = game.Players:GetPlayerFromCharacter(hit.Parent)
            player.leaderstats.Coins.Value = player.leaderstats.Coins.Value + 10
            script.Sound:Play()
        end
    end 
end)
0
connect is deprecated use Connect green271 635 — 5y
0
It was working fine until I used Connect. The character touches it and it disappears & receives no points. PrincessPaige12345 -3 — 5y
0
Changing connect to Connect will not negatively affect your script in any way. Also, changing the transparency to 1 is not the best way to go about this. Changing the transparency will only make the coin invisible, meaning if the player touches it, they will still receive points. You can instead change the coin's parent to nil and set it back to whatever it was parented to to begin with after lunatic5 409 — 5y
0
the amount of time you'd like the coin to regenerate. lunatic5 409 — 5y

Answer this question