hey i was coding but i got this error
game.Players.PlayerRemoving:Connect(function(player)
local ID = "currencyName".."-"..player.UserId
DateStore:SetAsync(ID,player.leadersats[currencyName].Value)
end)
hey i was coding but i got this error
game.Players.PlayerRemoving:Connect(function(player)
local ID = "currencyName".."-"..player.UserId
DateStore:SetAsync(ID,player.leadersats[currencyName].Value)
end)
What is the error? Without this we can’t help you
EDIT: As @Nerkonl posted the same question as me, i will change my question: where line?
What’s the error?
30 charssssssssssssssssssss
it says
DateStore:SetAsync(ID,player.leadersats[currencyName].Value)
edit leaderstats is not a valid member of player
Ok, but the error message? Still can’t help
leaderstats is not a valid member of player
How do you have add the Folder? Via local or server (server == normal) script? If you added it via local script, then move it to server.
Do you are sure that the folder exist on the server side?
You put player.leadersats
“leadersats”
You should put player.leaderstats[currencyName].Value
I think that fixes your problem, if my post is the solution then please mark it as the solution.
If you can then yes, this would more help us.
leaderstats is not inside a player, the script run first before leaderstats was added.
You also got wrong spelling (You wrote “leadersats” instead of “leaderstats”)
So the solution is Wait for leaderstats to added.
DateStore:SetAsync(ID,player:WaitForChild("leaderstats")[currencyName].Value)
Just like @Firzal_VX said use the ROBLOX built in function :WaitForChild and also fix the spelling mistake of “player.leadersats”
Are you sure that you published the game and have enabled API access in the Game Settings?
Can you try changing this to currency.Parent = leaderstats ?
maybe that’s the problem.
if i do then the code breaks
30car
always double check spellings.
already changed that
30 chaaahah
got a new error Money is not a valid member of Folder
First Test in game, not in Studio, then if it still don’t work so try this:
local succes, Data = pcall(function()
return savedData = DateStore:GetAsync(ID)
end)
if succes then
if Data then
currency.Value = data
print("Data loaded")
else --new player
currency.Value= 50
print("New player to the game")
end
end
P.S.: its the Value you change not the name, so not currency.Name = 50, but currency.Value = 50
This should help you with the Money error