Ill help you fix that,
game.Players.PlayerAdded:Connect(function(player)
local data
local success, errormessage = pcall(function()
data = MyData:GetAsync(player.UserId)
end)
if success then
data = data --Your error: Why are you setting the userid of the player to the data?
else
print("Error Getting Data")
warn(errormessage)
end
end)
idk, im school rn and im trying to code while studying
Well it should work, also, study first.
you should save all data into one.
10:55:42.691 ServerScriptService.NonPowers.DataStore.DataStore:7: attempt to call a table value - Server - DataStore:14, this error came?
you can remove the data = data btw.
oh wait i forgot to remove something, maybe it works now
hm, there are no errors but either it wont load or it wont save
Can you send the entire script?
here
local DataSS = game:GetService("DataStoreService")
local MyData = DataSS:GetDataStore("MyDataStore")
game.Players.PlayerAdded:Connect(function(player)
local data
local success, errormessage = pcall(function()
data = MyData:GetAsync(player.UserId)
end)
if success then
print("Data Loaded")
else
print("Error Getting Data")
warn(errormessage)
end
end)
game.Players.PlayerRemoving:Connect(function(player)
local success, errormessage = pcall(function()
local playerData = {
["DataId"] = 0,
["Level"] = player.GLevel.Value,
["Exp"] = player.GLevel.Current.Value,
["SLevel"] = player.SLvl.Value,
["Exp2"] = player.SLvl.Exp.Value,
["FLevel"] = player.FLvl.Value,
["Exp3"] = player.FLvl.Exp.Value,
["SpawnL"] = player.SpawnL.Value,
["Fruit"] = player.Fruit.Value,
["Sword"] = player.Sword.Value,
["Melee"] = player.Melee.Value
}
MyData:UpdateAsync(player.UserId,function(oldValue)
local pValue = oldValue or {DataId = 0}
if playerData.DataId == pValue.DataId then
playerData.da = playerData.DataId + 1
return playerData
else
return nil
end
end)
end)
if success then
print("Data Saved")
else
print("DataSave Falied")
warn(errormessage)
end
end)
game:BindToClose(function()
wait(.5)
end)
What is Glevel? Is it a value?
player.Glevel means that there is a IntVapue inside the player
GLevel is short for Geppo Level, and yes its a value
its a int value yes aaaaaaaaaa
Well you forgot to put the loaded values into the player
ok, but i need to know how because im used to the basic data store. that you learn on youtube
wait i maybe figured out something
wait nvm. aaaaaaaaaaaaaaaaaa
Firstly when the player joins, you check if the data of the player is nil or not. If it is nil or is not success the Data that will be saved is the default value.
When saving the data, you check the Data id which is set to 0 as default and check if the saved value is the same as the data id. If yes then you save the value as that else there was an error in loading because it is not the same.
ok, tbh i cant figure out how to check if the data is nil or not, but i cant awnser for a while but ill try my best when im back
hey you still online? aaaaaaa