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

this datastore script dosent save the in value why??

Asked by 4 years ago

this script doesnt save and i enable api services can any one help me

local DataStoreService = game:GetService("DataStoreService")
local DataStore5 = DataStoreService:GetDataStore("DataStore5")

game.Players.PlayerAdded:Connect(function(player)
    wait(0.1)
    local Jump = Instance.new("IntValue")
    Jump.Name = "Jump"
    Jump.Parent = player.leaderstats

    local playerUserId = "Player_"..player.UserId

    local success, errormessage = pcall(function()
         data = DataStore5:GetAsync(playerUserId)
    end)

    if success then
        Jump.Value = data
        -- set our data = to current cash
    end

end)

game.Players.PlayerRemoving:Connect(function(player)
    local playerUserId = "Player_"..player.UserId
    local Data1 = player.leaderstats.Jump.Value

    local success, errormessage = pcall(function()
        DataStore5:SetAsync(playerUserId,Data1)
    end)

    if success then
        print("DataSaved")
    else 
        print("ThereWasAnError")
        warn(errormessage)
    end
    print("done")
end)
0
im not sure but u should combine the script that makes the leaderstats HappyTimIsHim 652 — 4y

Answer this question