Hello, I have made a folder inside of a pet to add hunger, age etc.
But when i check, the hunger value is not named to “hunger” instead its just “Value” and the value I set it to (100) is 0. all the other stats work.
Script:
local statsDataStore = dataStoreService:GetDataStore("MaxwellStats")
game.Players.PlayerAdded:Connect(function(player)
local maxwellStatsFolder = Instance.new("Folder", player)
maxwellStatsFolder.Name = "MaxStats"
local age = Instance.new("IntValue", maxwellStatsFolder)
age.Name = "Age"
age.Value = 1
local hunger = Instance.new("IntValue", maxwellStatsFolder)
hunger.Name = "Hunger"
hunger.Value = 100
local happiness = Instance.new("IntValue", maxwellStatsFolder)
hunger.Name = "Happiness"
hunger.Value = 100
local statsData = statsDataStore:GetAsync(player.UserId)
if statsData ~= nil then
age.Value = statsData[1]
hunger.Value = statsData[2]
happiness.Value = statsData[3]
end
end)
game.Players.PlayerRemoving:Connect(function(player)
local statsData = {}
for _, child in pairs(player.MaxStats:GetChildren()) do
table.insert(statsData,child.Value)
end
pcall(function()
statsDataStore:SetAsync(player.UserId,statsData)
end)
end)
game:BindToClose(function()
for _, player in pairs(game.Players:GetPlayers()) do
local statsData = {}
for _, child in pairs(player.MaxStats:GetChildren()) do
table.insert(statsData,child.Value)
end
pcall(function()
statsDataStore:SetAsync(player.UserId,statsData)
end)
end
end)
proof:
Why?