Where are the scripts located, and which type of scripts are they?
Print Player and PlayerName and check if they’re valid
Print along the script to see where it fails
Print Player.leaderstats:FindFirstChild(“Tokens”) right after the Instance to check if it was added successfully
Just a tip, you can actually do
local Currency = CurrencyStore:GetAsync(UserId) or 0 -- if no "Currency" then assign it to 0
instead of
local Currency = CurrencyStore:GetAsync(UserId)
if Currency == nil then
Currency = 0
end
And you can also do Tokens.Value += 1 instead of Tokens.Value = Tokens.Value + 1
I’d suggest making a print function straight after you create the Tokens value, and ensuring that it exists by printing the player’s tokens. If it does print, then it’s probably because the remote event is firing before the tokens are actually created, which can be fixed by changing this (replicated storage):
local Tokens = Player.leaderstats.Tokens
To this:
local Tokens = Player.leaderstats:WaitForChild("Tokens")