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)