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

Can anyone tell me why this datastore script I found doesn't save?

Asked by 1 year ago

found this youtube video on datastores and wanted to try it out but for some reason it doesnt load in the level value(and it wont display the level value either)

local DataStoreService = game:GetService("DataStoreService")

local LevelSave = DataStoreService:GetDataStore("PLevel")

local LevelLable = game.StarterGui.TopLeftGui.LevelGui.LevelLabel

game.Players.PlayerAdded:Connect(function(plr)

local Level = Instance.new("IntValue")

    Level.Name = "Level"
    Level.Parent = plr 
    LevelLable.Text = "Level:"..Level.Value
    local success, errormessage = pcall(function()
        LevelSave:GetAsync(plr.UserId, plr.Level.Value)
    end)
    if success then
        print("cool")
    else
        print("there was an error whilst printing your data")
        warn(errormessage)

    end
end)

game.Players.PlayerRemoving:Connect(function(plr)
  local success, errormessage = pcall(function()
LevelSave:SetAsync(plr.UserId, plr.Level.Value)
        end)
    if success  then
        print("yes")
    else
        print("no")
        warn(errormessage)
end
end)
0
I do not know how your leaderstats work but I do not see anywhere you setting Level.Value to data you got from datastore. Sabailuridze 126 — 1y
0
how would I do that? StevenElijah7019 57 — 1y

1 answer

Log in to vote
0
Answered by
enes223 327 Moderation Voter
1 year ago

hey you! have you ever heard of enes? if you are in trouble, better call enes!

Ad

Answer this question