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

Trying to make this script respawn a coin but dont know were I went wrong, help?

Asked by 4 years ago
Edited 4 years ago

debounce = false

script.Parent.Touched:Connect(function(hit)

if debounce == false then

debounce = true

    if hit.Parent:FindFirstChild("Humanoid") then

        local plr = game.Players:GetPlayerFromCharacter(hit.Parent)

            if plr~=nil then

                if plr:FindFirstChild("Stats") and plr:FindFirstChild("Main") and plr.Main:FindFirstChild("CandysQ3") and  plr.Stats:FindFirstChild("????Candys") and 

plr.Main:FindFirstChild("BoostCandy") then

                    local coins = plr.Stats["????Candys"]

                    local CandysQ3 = plr.Main["CandysQ3"]

                        if plr:WaitForChild("Main").BoostCandy.Value == 0 then

                            coins.Value = coins.Value + 1

                            CandysQ3.Value = CandysQ3.Value + 1
                        else

                            coins.Value = coins.Value + 

1+plr:WaitForChild("Main").BoostCandy.Value CandysQ3.Value = CandysQ3.Value + 1

                        end
                    end
                end
            script.Parent:Destroy()
        end
    debounce = false
end

end)

0
Fix the code block. namespace25 594 — 4y

1 answer

Log in to vote
0
Answered by 4 years ago

You did not create the coin so you would need to do:

debounce = true

    if hit.Parent:FindFirstChild("Humanoid") then

        local plr = game.Players:GetPlayerFromCharacter(hit.Parent)

            if plr~=nil then

                if plr:FindFirstChild("Stats") and plr:FindFirstChild("Main") and plr.Main:FindFirstChild("CandysQ3") and  plr.Stats:FindFirstChild("????Candys") and 

plr.Main:FindFirstChild("BoostCandy") then

local coins = plr.Stats["????Candys"]

local CandysQ3 = plr.Main["CandysQ3"]

    if plr:WaitForChild("Main").BoostCandy.Value == 0 then

        coins.Value = coins.Value + 1

        CandysQ3.Value = CandysQ3.Value + 1
    else

        coins.Value = coins.Value + 

1+plr:WaitForChild("Main").BoostCandy.Value CandysQ3.Value = CandysQ3.Value + 1

                        end
                    end
                end
        local coin_clone = script.Parent:Clone()
            coin_clone.CFrame = script.Parent.CFrame
            script.Parent:Destroy()
        end
    debounce = false
end
0
would that make it respawn? MiniiAk47 0 — 4y
Ad

Answer this question