Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Why doesn't this DataStore saving work with my game?

Asked by 3 years ago
Edited 3 years ago

So, I'm making a DataStore (to save the time of the game) and it is not working. I was looking on the Developer Page for Data Stores and was following the instructions. I have no clue on how to fix this. Edited Code: (no error and only part of Script)

local data = game:GetService("DataStoreService")
local datastore = data:GetDataStore("ClockTime")

game.Lighting.ClockTime = datastore

game.Close:Connect(function()   
    local success, err = pcall(function()
        datastore:SetAsync(game.Players:FindFirstChildOfClass("Player").UserId, 50)
    end)
end)

It is setting the ClockTime to 0 every time I join in my game car (and in studio). I do have API Services Enabled.

Thanks, b_mni.

Answer this question