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)

7 comments
What line?
http://idownvotedbecau.se/noexceptiondetails
Rebirths doesnt exist then. what your referencing doesnt exist
did you make a leaderstats script
Line 15
And yes I did make a leaderstats script
Never mind guys I fixed it. Thanks for wanting to help!