How do you make it so when a player joins, it checks if he has DataStore and if no, create the data by setting it to 1? (And will the server be able to read a data that is 0?)
✓ ANSWER ACCEPTED
On join, if no data, set data to 0?
1 answer
✓ Accepted answer
You don't need to check if the player has joined before, you just have to check if the player has said DataStore.
local DDS = game:GetService("DataStoreService")
local dataStore = DDS:GetDataStore("joinedBefore")
game.Players.PlayerAdded:connect(function(plr)
local s,f = pcall(function()
ds = dataStore:GetAsync(plr.UserId)
end)
if s and ds then
print(ds)
else
print("no ds, creating a new one")
pcall(function()
dataStore:SetASync(plr.UserId, "info")
end)
end
end)
This discussion is preserved as it was. New answers, comments, and votes are closed.

3 comments
If you need any more help, don't hesitate to contact me!
It always say that there is no data?
Nevermind! Thanks