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

How do I fix the error in this script?

Asked by 4 years ago
Edited 4 years ago

So I'm trying to make it so when a button on a gui is clicked it sends a signal to the remote event. If the player has enough coins to rebirth it does the following: resets coins, gives 10 rebirth tokens. But what I'm having an error on is when I am trying to delete all the coins bought, it won't delete. Please help me find the solution to this error.

Error: attempt to index local 'Rebirths' (a nil value)

game.ReplicatedStorage.RemoteEvents.Rebirth.OnServerEvent:Connect(function(plr)
    local rebirths = plr.leaderstats.Rebirths
    local str = plr.leaderstats.Coins
    local neededStr = (rebirths.Value + 1) * 15000000
    local rt = plr.leaderstats.Rebirths.RebirthTokens

    if str.Value >= neededStr then
        rebirths.Value = rebirths.Value + 1
        rebirths.Boost.Value = rebirths.Boost.Value + 1
        plr.leaderstats.Rebirths.RebirthTokens.Value = plr.leaderstats.Rebirths.RebirthTokens.Value + 10
        plr.ItemEquipped.Value = "Bronze Coin"
        local items = plr.Items
        items:WaitForChild("Bronze Coin").Parent = plr
        local ri = plr.Items:GetChildren()
        ri:Destroy()
        plr:WaitForChild("Bronze Coin").Parent = plr.Items
        str.Value = 0
        plr:LoadCharacter()
    end
end)
0
What line? xxViralityxx -9 — 4y
0
Rebirths doesnt exist then. what your referencing doesnt exist Tyler090130 619 — 4y
0
did you make a leaderstats script 123nabilben123 499 — 4y
View all comments (3 more)
0
Line 15 Ericksosa101 0 — 4y
0
And yes I did make a leaderstats script Ericksosa101 0 — 4y
0
Never mind guys I fixed it. Thanks for wanting to help! Ericksosa101 0 — 4y

Answer this question