Hello!
I’ve been working on my game and I made a datastore. (Well, I didnt actually make it. It was from a tutorial.)
My datastore has been working!.. but…
It seems it has a ‘capacity’
If I am saving more than 4 values, well, it just doesnt save.
This might not be a problem with my script, but i’ll show you it anyways.
local dataStoreService = game:GetService("DataStoreService")
local clientDataStore = dataStoreService:GetDataStore("DataStore")
game.Players.PlayerAdded:Connect(function(plr)
plr.CharacterAdded:Connect(function(char)
local Values = Instance.new("Folder")
Values.Name = "Values"
Values.Parent = plr
local SpecialDamage = Instance.new("IntValue")
SpecialDamage.Name = "SpecialDamage"
SpecialDamage.Parent = Values
local SpecialCritDamage = Instance.new("IntValue")
SpecialCritDamage.Name = "SpecialCritDamage"
SpecialCritDamage.Parent = Values
local Level = Instance.new("IntValue")
Level.Name = "Level"
Level.Parent = Values
local NumberOfAbnormalStats = Instance.new("IntValue")
NumberOfAbnormalStats.Name = "NumberOfAbnormalStats"
NumberOfAbnormalStats.Parent = Values
local NumOfKicks = Instance.new("IntValue")
NumOfKicks.Name = "NumOfKicks"
NumOfKicks.Parent = Values
local SpecialEnabled = Instance.new("BoolValue")
SpecialEnabled.Name = "SpecialEnabled"
SpecialEnabled.Parent = Values
local Beheaded = Instance.new("BoolValue")
Beheaded.Name = "Beheaded"
Beheaded.Parent = Values
local SwingSpecial = Instance.new("BoolValue")
SwingSpecial.Name = "SwingSpecial"
SwingSpecial.Parent = Values
local StunSpecial = Instance.new("BoolValue")
StunSpecial.Name = "StunSpecial"
StunSpecial.Parent = Values
local playerUserId = "Player_"..plr.UserId
--load player data--
local data
local success, errormessage = pcall(function()
data = clientDataStore:GetAsync(playerUserId)
end)
if success then
SpecialDamage.Value = data.SpecialDamage
SpecialCritDamage.Value = data.SpecialCritDamage
NumberOfAbnormalStats.Value = data.NumberOfAbnormalStats
NumOfKicks.Value = data.NumOfKicks
--SwingSpecial.Value = data.SwingSpecial
--StunSpecial.Value = data.StunSpecial
--Level.Value = data.Level
end
end)
end)
function saveData(plr)
local playerUserId = "Player_"..plr.UserId
local data = {
SpecialDamage = plr.Values.SpecialDamage.Value,
SpecialCritDamage = plr.Values.SpecialCritDamage.Value,
NumberOfAbnormalStats = plr.Values.NumberOfAbnormalStats.Value,
NumOfKicks = plr.Values.NumOfKicks.Value,
--SwingSpecial = plr.Values.SwingSpecial,
--StunSpecial = plr.Values.StunSpecial,
--Level = plr.Values.Level.Value
}
local success, errormessage = pcall(function()
clientDataStore:SetAsync(playerUserId, data)
end)
if success then
print("data successfully saved for "..playerUserId)
else
print("error saving data for "..playerUserId)
end
end
game.Players.PlayerRemoving:Connect(saveData)
The reason why there is “–” in some parts is because it just wouldnt work if I got rid of the comments.
Like I said, it cant hold more than 4 values. and I need more than 4.
local datathing = {thecoinsorsomething,anotherstatorsomething} -- etc
datastore:SetAsync(key,datathing)
local fetch = datastore:GetAsync(key)
coins.value = fetch[1] -- do this kind of but like in the order of what you stored
Nope. The player data is still not being saved. It gives me the same error message I implemented when it fails saving. “error saving data for (my userid)”
Are you in studio? If so, turn on studio access to api services in the settings menu. It should be located under the security tab. If not enabled, data stores will not function outside of the real game.
As I said in the post, my problem isnt the script kinda… it just seems datastore has a “capacity” that I have no idea if im past or not. The values I made shouldnt be more than 4MB.
You can only use game.Players.LocalPlayer on the Client, not the Server. Are you storing your data for each player on the Client? Make sure to save and load data on the Server
Like where’s the bit with the game.Players.LocalPlayer:Kick()? You can’t do that on the server, as I stated before, you can only do that on the Client. I’m taking about the part above when someone asked is “Enable access to studio api services” on
Oh. I use game.Players.LocalPlayer:Kick inside of roblox studio command bar
Also, is it just me, or are you going completely off-topic? the problem is my datastore isnt saving. Not that I cant kick someone on a serverscript even though I wasnt using a server script to kick the player