Why does my datastore only saves 2 values numbervalue and BoolValue and when i try to.add another BoolValue it wont work. The only two values only works
--- ----- DataStore
local dss = game:GetService("DataStoreService")
local db = dss:GetDataStore("IvanozDataStore")
game.Players.PlayerAdded:Connect(function(player)
local leaderstats = Instance.new("Folder",player)
leaderstats.Name = "leaderstats"
local ownsTool = Instance.new("BoolValue",player)
ownsTool.Value = false
ownsTool.Name = "ownsTool"
local ownsMagnumTool = Instance.new("BoolValue",player)
ownsMagnumTool.Value = false
ownsMagnumTool.Name = "ownsMagnumTool"
local coins = Instance.new("NumberValue",leaderstats)
coins.Name = "Coins"
coins.Value = 200
local ownsToolData
local ownsMagnumData
local coinsData
local succes,errorMessage = pcall(function()
ownsToolData = db:GetAsync(player.UserId.."-ownsTool")
coinsData = db:GetAsync(player.UserId.."-coins")
ownsMagnumData = db:GetAsync(player.UserId.."-ownsMagnumData")
end)
if succes then
ownsTool.Value = ownsToolData
coins.Value = coinsData
ownsMagnumTool.Value = ownsMagnumData
else
warn(errorMessage)
end
player.CharacterAdded:Connect(function(char)
if player.ownsTool.Value == true and not player.StarterGear:FindFirstChild("Axe") then
game.ServerStorage:WaitForChild("Tools").Axe:Clone().Parent = player:WaitForChild("StarterGear")
game.ServerStorage:WaitForChild("Tools").Axe:Clone().Parent = player:WaitForChild("Backpack")
end
if player.ownsMagnumTool.Value == true and not player.StarterGear:FindFirstChild("Magnum") then
game.ServerStorage:WaitForChild("Tools").Magnum:Clone().Parent = player:WaitForChild("StarterGear")
game.ServerStorage:WaitForChild("Tools").Magnum:Clone().Parent = player:WaitForChild("Backpack")
end
end)
end)
game.Players.PlayerRemoving:Connect(function(player)
db:SetAsync(player.UserId.."-ownsTool",player.ownsTool.Value)
db:SetAsync(player.UserId.."-coins",player.leaderstats.Coins.Value)
db:SetAsync(player.UserId.."-ownsMagnumTool",player.ownsMagnumTool.Value)
end)