I think I typed this right. But i keep getting a annoying error in the output. "leaderstats is not a valid member of player" even though it is a valid member of player.
01 | local playerstats = game.Players.LocalPlayer.leaderstats.Coins |
02 | local playerstats 2 = game.Players.LocalPlayer.leaderstats.Clicks |
03 | local aneeded = 1000 |
04 |
05 | function exchange() |
06 | if playerstats 2. Value > = aneeded then playerstats 2. Value = playerstats 2. Value - aneeded and playerstats.Value = = playerstats.Value + 1 |
07 | end |
08 | end |
09 |
10 | script.Parent.MouseButton 1 Click:Connect(exchange) |
That sometimes happen because the script is replicated some miliseconds before the leaderstats and then it does not find it, the way you can fix it is using :WaitForChild()
1 | local playerstats = game.Players.LocalPlayer:WaitForChild( "leaderstats" ).Coins |
does not need to do that for the second variable since it will only execute the rest when leaderstats was detected.