Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

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

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)

2 comments

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.

0

how would I do that?

1 answer

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

This discussion is preserved as it was. New answers, comments, and votes are closed.