So I have a datastore and leaderboard script with three different stats in it and one of them has a space in it, how would I save that? Because with what I have, whenever I join in the game, edit the stats, then leave and rejoin the stats don't save, so maybe its the third stat?
local DS = game:GetService("DataStoreService")
game.Players.PlayerAdded:connect(function(plr)
local ls = Instance.new("Folder",plr)
ls.Name = "leaderstats"
local cash = Instance.new("NumberValue", ls)
cash.Name = "Cash"
local rank = Instance.new("StringValue", ls)
rank.Name = "Rank"
local blocksm = Instance.new("NumberValue", ls)
blocksm.Name = "Blocks Mined"
local id = plr.userId
cash.Value = DS:GetDataStore("cash"):GetAsync(id) or 0
rank.Value = DS:GetDataStore("ranks"):GetAsync(id) or "Beginner Miner"
blocksm.Value = DS:GetDataStore("blocksm"):GetAsync(id) or 0
end)
game.Players.PlayerRemoving:connect(function(plr)
local id = plr.userId
local ls = plr:FindFirstChild("leaderstats")
if ls and id then
DS:GetDataStore("cash"):SetAsync(id, ls.Cash.Value)
DS:GetDataStore("ranks"):SetAsync(id, ls.Rank.Value)
DS:GetDataStore("blocksm"):SetAsync(id, ls.BlocksMined.Value)
end
end)
My game is FE.

5 comments
Please use code blocks in your post so I can read it.
sorry, fixed it
Use :FindFirstChild("Blocks Mined")
Object["Child Name] or Object:FindFirstChild("Child Name") or even Object:WaitForChild("Child Name")
ok thanks