Problem with DataStore

I made this script

ServerScriptService - Normal Script

local DataStore = game:GetService("DataStoreService")
local DS1 = DataStore:GetDataStore("DS1")

game.Players.PlayerAdded:Connect(function(player)
    DS1:SetAsync(player.UserId, "text")
end)

but isn’t working, when i try see the DataStore, i don’t have anything in DS1, its empty

I would recommend using pcalls to prevent it from bugging out.

local DataStore = game:GetService("DataStoreService")
local DS1 = DataStore:GetDataStore("DS1")

game.Players.PlayerAdded:Connect(function(player)
    local success, fail = pcall(function()
DS1:SetAsync(player.UserId, "text")
end)
end)

Also, make sure if you’re testing in studio that API Services are enabled.

1 Like
local DataStore = game:GetService("DataStoreService")
local DS1 = DataStore:GetDataStore("DS1")

game.Players.PlayerAdded:Connect(function(player)
    local success,err = pcall(function()
        DS1:SetAsync(player.UserId, "text")
    end)
    if not success then
        warn("Couldn't save data")
end)
1 Like

you forget a “end” in the script

Oh, my bad. Did it work though?

1 Like

wait pls, im testing if the script works

No, but i dont understand, i used in other game and worked…
Idk why my new game cant run the script (i used prints and warns and nothing in output)