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

Saving/Loading Data error GlobalDataStore error?

Asked by
imKlevi 94
4 years ago

1012714707-MaxHealth is not a valid member of GlobalDataStore
why this error when i try to save game?

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


game.Players.PlayerAdded:Connect(function(player)
    local data
    local success, errormessage = pcall(function()
        data = myDataStore:GetAsync(player.UserId.."-MaxHealth")
    end)
    if success then
        print("Successfully loaded your data!")
        else
        print("Your Data failed to load!")
        warn(errormessage)
    end
end)

game.Players.PlayerRemoving:Connect(function(player)

   local success, errormessage = pcall(function()
    myDataStore(player.UserId.."-MaxHealth",player.MaxHealth.Value)
  end)
  if success then 
    print("Your Data Successfully Saved!")
  else
    print("Your Data Has Ben Corrupted and failed to save!")
    print(errormessage)
end
end)
0
Is MaxHealth directly under player or is it in a folder? ZSQD_royalzombie222 0 — 4y
0
ZSQD_royalzombie222 is game.Players.LocalPlayer.MaxHealth.Value imKlevi 94 — 4y

Answer this question