I want to be able to add the person 500k Credits when they join the game for the first time.
Right now I have a script that saves both leaderstats, however I want the person to start out with 500k credits.
If I set it that the user always has 500k, then every time they join the game they’re going to reset to 500k credits again.
Essentially I need a way to check if a person is joining for the first time, and if so, add them 500k to their Credits.
Then your going to have to user DataStore to save a value called like hasJoined, and if its there first time joining make hasJoined true and then when you give players credits when they first join just check if they have joined already
Use BoolValues(I guess?). Like, make a boolvalue called “Claimed500k” and when the user joins the game, check if the value of this is set to false. If so, give the user his/her 500k, and set the value to true and save this through a datastore. You don’t really have to use boolvalues though, you can simply use datastores as “IProgramForFun” said, depends on your choice.
Also use datastore2 it helps you save so easily since this is a dictionary
I also recommend you use this data structure for keeping player data organized
_G.Data = {}
game.Players.PlayerAdded:Connect(function(player)
_G.Data[player.UserId]["hasJoined"] = false
_G.Data[player.UserId]["Credits"] = 0
-- new player
if not _G.Data[player.UserId]["hasJoined"] then
-- award credits
else
-- not a new player
end
end)