This error seems like a very big thing to rely on not happening. Is there any way I can stop this from happening or is it a roblox bug?
In case its something with my script, heres my script
local DataStoreService = game:GetService("DataStoreService")
local DataStore = DataStoreService:GetDataStore("DataStoreValues")
local Players = game:GetService("Players")
Players.PlayerAdded:Connect(function(Player)
local Coldata --giving them a variable
local Leveldata --giving them a variable
local Levelexpdata
local Blacksmithdata
local Blacksmithexp
local Scythedata
local Rapierdata
local Greatsworddata
local Straightsworddata
local Daggerdata
local Scytheexpdata
local Rapierexpdata
local Greatswordexpdata
local Straightswordexpdata
local Daggerexpdata
local s, e = pcall(function()
Coldata = DataStore:GetAsync(Player.UserId.."-Coldata") or 0 --check if they have data, if not it'll be "0"
Blacksmithdata = DataStore:GetAsync(Player.UserId.."-Blacksmithdata") or 0
Blacksmithexp = DataStore:GetAsync(Player.UserId.."-Blacksmithexp") or 0
Leveldata = DataStore:GetAsync(Player.UserId.."-Leveldata") or 1--check if they have data, if not it'll be "1"
Levelexpdata = DataStore:GetAsync(Player.UserId.."-Levelexpdata") or 0
Scythedata = DataStore:GetAsync(Player.UserId.."-Scythedata") or 0
Rapierdata = DataStore:GetAsync(Player.UserId.."-Rapierdata") or 0
Greatsworddata = DataStore:GetAsync(Player.UserId.."-Greatsworddata") or 0
Straightsworddata = DataStore:GetAsync(Player.UserId.."-Straightsworddata") or 0
Daggerdata = DataStore:GetAsync(Player.UserId.."-Daggerdata") or 0
Scytheexpdata = DataStore:GetAsync(Player.UserId.."-Scytheexpdata") or 0
Rapierexpdata = DataStore:GetAsync(Player.UserId.."-Rapierexpdata") or 0
Greatswordexpdata = DataStore:GetAsync(Player.UserId.."-Greatswordexpdata") or 0
Straightswordexpdata = DataStore:GetAsync(Player.UserId.."-Straightswordexpdata") or 0
Daggerexpdata = DataStore:GetAsync(Player.UserId.."-Daggerexpdata") or 0
end)
if s then
print("Success")
Player:WaitForChild("Skills").Blacksmithskill.Value = Blacksmithdata
Player:WaitForChild("Skills").Blacksmithskill.Exp.Value = Blacksmithexp
Player:WaitForChild("Level").Value = Leveldata --setting data if its success
Player:WaitForChild("Values").Col.Value = Coldata --setting data if its success
Player:WaitForChild("Level").Exp.Value = Levelexpdata
Player:WaitForChild("Skills").Swordskills.Rapierskill.Value = Rapierdata
Player:WaitForChild("Skills").Swordskills.Scytheskill.Value = Scythedata
Player:WaitForChild("Skills").Swordskills.Greatswordskill.Value = Greatsworddata
Player:WaitForChild("Skills").Swordskills.Straightswordskill.Value = Straightsworddata
Player:WaitForChild("Skills").Swordskills.Daggerskill.Value = Daggerdata
Player:WaitForChild("Skills").Swordskills.Daggerskill.Exp.Value = Daggerexpdata
Player:WaitForChild("Skills").Swordskills.Rapierskill.Exp.Value = Rapierexpdata
Player:WaitForChild("Skills").Swordskills.Greatswordskill.Exp.Value = Greatswordexpdata
Player:WaitForChild("Skills").Swordskills.Scytheskill.Exp.Value = Scytheexpdata
Player:WaitForChild("Skills").Swordskills.Straightswordskill.Exp.Value = Straightswordexpdata
else
game:GetService("TestService"):Error(e) --if not success then we error it to the console
end
end)
Players.PlayerRemoving:Connect(function(Player)
local s, e = pcall(function()
print("Success")
DataStore:SetAsync(Player.UserId.."-Coldata", Player.Values.Col.Value) --setting data
DataStore:SetAsync(Player.UserId.."-Blacksmithdata", Player.Skills.Blacksmithskill.Value)
DataStore:SetAsync(Player.UserId.."-Blacksmithexp", Player.Skills.Blacksmithskill.Exp.Value)
DataStore:SetAsync(Player.UserId.."-Leveldata", Player.Level.Value) --setting data
DataStore:SetAsync(Player.UserId.."-Levelexpdata", Player.Level.Exp.Value)
DataStore:SetAsync(Player.UserId.."-Scythedata", Player.Skills.Swordskills.Scytheskill.Value)
DataStore:SetAsync(Player.UserId.."-Rapierdata", Player.Skills.Swordskills.Rapierskill.Value)
DataStore:SetAsync(Player.UserId.."-Greatsworddata", Player.Skills.Swordskills.Greatswordskill.Value)
DataStore:SetAsync(Player.UserId.."-Straightsworddata", Player.Skills.Swordskills.Straightswordskill.Value)
DataStore:SetAsync(Player.UserId.."-Daggerdata", Player.Skills.Swordskills.Daggerskill.Value)
DataStore:SetAsync(Player.UserId.."-Daggerexpdata", Player.Skills.Swordskills.Daggerskill.Exp.Value)
DataStore:SetAsync(Player.UserId.."-Rapierexpdata", Player.Skills.Swordskills.Rapierskill.Exp.Value)
DataStore:SetAsync(Player.UserId.."-Greatswordexpdata", Player.Skills.Swordskills.Greatswordskill.Exp.Value)
DataStore:SetAsync(Player.UserId.."-Scytheexpdata", Player.Skills.Swordskills.Scytheskill.Exp.Value)
DataStore:SetAsync(Player.UserId.."-Straightswordexpdata", Player.Skills.Swordskills.Straightswordskill.Exp.Value)
end)
if not s then game:GetService("TestService"):Error(e) end --if not success then error
end)
Edit: It still saves all the data if I rejoin again, but certain times Ill just join the game and all the data will be gone.