Whenever I run my data script to obviously save and load things, I made functions to go through and load data, then made a function to be called multiple times and load, but anyway, thats not related. Using this script, I, the player is kicked from the game as the script does. Although it shouldnt..? This may be an incredibly stupid mistake... It's stumped me because the whole game relies on this.
function LoadItem(Data2,DataType,PlayerID, Parent, Player) local F local Scope = "Player_" .. PlayerID local Data = DataStore:GetDataStore("Data", Scope) if DataType == "Number" then F = Instance.new("NumberValue", Parent) elseif DataType == "Int" then F = Instance.new("IntValue", Parent) elseif DataType == "String" then F = Instance.new("StringValue", Parent) elseif DataType == "Bool" then F = Instance.new("BoolValue", Parent) end F.Name = Data2 repeat Tries = Tries + 1 local Sucess, Temp = pcall(function() return Data:GetAsync(Data) end) if not Success then wait(1) end until Tries == ALLOWED_RETRIES or Success if not Success then PWE:FireClient(Player, "Warn", "ROBLOX's DataStoreService may be offline. Please try again later. We have kicked you to prevent you losing your data.") wait(2) Player:Kick("ROBLOX's DataStoreService may be offline. Please try again later. We have kicked you to prevent you losing your data.") end F.Value = Temp Temp = nil end
return Data:GetAsync(Data)
is wrong (should it be return Data:GetAsync(Data2)
?). To prevent such errors in the future, consider logging/printing out whatever 'Temp' is -- it is the error message when 'Success' is false.
Note that it would be more efficient if you loaded/saved a single table with all the needed values instead of loading/saving to several different keys per player (especially since there are limits on how frequently you can load/save a single key (see limitations here: http://wiki.roblox.com/index.php?title=Data_store). So long as the table isn't huge (and either only uses string keys or is a list), it will save/load correctly (and will only count as 1 request).
facepalm it was a spelling mistake... Success was spelt wrong ...