Value not showing up?

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?

Here’s the problem, the selected box.


It set’s the hunger value name to “happiness”, instead of the original happiness variable.

1 Like

Simply because you set the name to Happiness. Common mistake, You did set the name to hunger in the start but you forgot to change the variable which then resulted in the name being overwritten

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.