that wont work for the game so i cant
Is this your objective… or is this
Yeah, but look at this:
Players.PlayerRemoving:Connect(function(Player)
local PlayerDataTable = table.create(0, Player)
for i, v in pairs(Player.leaderstats:GetChildren()) do
table.insert(PlayerDataTable, v.Value)
end
PlayerData:SetAsync(Player.UserId, PlayerDataTable)
end)
You are saving from leaderstats folder and there is only two IntValues.
the top one. gggggggggggggggggggggggggg30chars
So very specifically to put it. Heres a solution
local Players = game:GetService("Players")
local DataStoreService = game:GetService("DataStoreService")
local HttpService = game:GetService("HttpService")
local PlayerData = DataStoreService:GetDataStore("PlayerData")
Players.PlayerAdded:Connect(function(Player)
-- Statistics
local Leaderstats = Instance.new("Folder", Player)
Leaderstats.Name = "leaderstats"
local Money = Instance.new("IntValue", Leaderstats)
Money.Name = "Money"
local Fans = Instance.new("IntValue", Leaderstats)
Fans.Name = "Fans"
-- Multipliers/Cosmetics
local Color = Instance.new("Color3Value", Leaderstats)
Color.Name = "Color"
local Material = Instance.new("StringValue", Leaderstats)
Material.Name = "Material"
local Data = PlayerData:GetAsync(Player.UserId)
if Data ~= nil then
Money.Value = Data["Money"].Value
Fans.Value = Data["Fans"].Value
Color.Value = Data["Color"].Value
Material.Value = Data["Material"].Value
else
Money.Value = 0
Fans.Value = 0
Color.Value = Color3.new(1, 1, 1)
Material.Value = "CorrodedMetal"
end
Money.Value += 5
end)
Players.PlayerRemoving:Connect(function(Player)
local PlayerDataTable = {}
for i, v in pairs(Player.leaderstats:GetChildren()) do
table.insert(PlayerDataTable, v.Value)
end
print(PlayerDataTable)
local JSONData = HttpService:JSONEncode(PlayerDataTable)
PlayerData:SetAsync(Player.UserId, JSONData)
end)
If this doesnt work. Ill use my DataStore module and fit it to your needs
Its currently grabbing from the nil values you had. Change the DataStore name to something different
Well, can you show how do you did that?
Players.PlayerRemoving:Connect(function(Player)
local PlayerDataTable = table.create(0, Player)
for i, v in pairs(Player.leaderstats:GetChildren()) do
table.insert(PlayerDataTable, v.Value)
end
for i, v in pairs(Player:GetChildren()) do
if v:IsA("IntValue") or v:IsA("StringValue") then
table.insert(PlayerDataTable, v.Value)
end
end
PlayerData:SetAsync(Player.UserId, PlayerDataTable)
end)
Think this would fix that.
Hydrous, it looks like your code doesn’t work because of this:
You change the Data[Number]'s to Data[String]'s. This doesn’t work because I need to use color. And you can only store values, like @TerrorThinks said earlier, if he was correct.
By the way it is better if you use a dictionary instead of a table for data stores because it will be easy to read I mean:
data.Value = Data[1]
data.Value = Data["Example"]
Ha! Found a fix after type checking
DataStoreFix.rbxm (2.5 KB)
Drag it into your ServerScriptService
His code is correct too. He’s converting numbers to string and then string to int back.
Data stores works with int, String and boolean values but not with objects or colors.
That’s amazing but there are a few “errors”.
They are:
Infinite yield possible on 'Players.Chickennuggetmanwow:WaitForChild("Material")'
And
16:16:09.994 Saving Money With Value 0 - Server - Script:76
16:16:09.994 Saving Material With Value Enum.Material.CorrodedMetal - Server - Script:76
16:16:09.994 Saving Color With Value 1, 0, 1 - Server - Script:76
16:16:09.994 Saving Fans With Value 0 - Server - Script:76
Otherwise though, this is perfect!
it does exist it works for me bro also that pic u showed wtf is that local value += value are u dumb
Interestingly, I never got such error. Try again if you don’t mind.
Actually, it is not the issue anymore but yeah now I already know. These operators didn’t use to exist the year I started to code in Roblox studio. My bad.
It seems like the infinite yield comes from LocalMap but all the other ones come from your script. Maybe the LocalMap is messing with it?
I also got an extra
16:20:38.594 Now loading... Chickennuggetmanwow Data - Server - Script:41
16:20:38.594 Loading Money With Value 0 - Server - Script:46
16:20:38.594 Loading Material With Value Enum.Material.CorrodedMetal - Server - Script:46
16:20:38.594 Loading Color With Value table: 0x83d1b772be0e0e53 - Server - Script:46
16:20:38.594 Loading Fans With Value 0 - Server - Script:46
16:20:43.740 Infinite yield possible on 'Players.Chickennuggetmanwow:WaitForChild("Material")' - Studio