Not getting the values correctly

local ServerStorage = game:GetService("ServerStorage")
local Players = game:GetService("Players")

Players.PlayerAdded:Connect(function(Player)
	ServerStorage.Values.Day:GetPropertyChangedSignal("Value"):Connect(function()
		for i,v in ipairs(game.Workspace[Player.Name]:GetDescendants()) do
			wait()
			if v:IsA("Model") then
				wait()
				local Pop = v.Values.AddedHousing
				print(Pop.Value)
				Player.Stats.Population.Value = Player.Stats.Population.Value + Pop.Value
				Pop.Value = 0
				print(Pop.Value)
			end
		end
	end)
end)

Problem is its not getting all the Houses in workspace. Its only getting the 1st one. Tried to get help elsewhere but to no avail. Any assistance?

1 Like

Which line is erroring? 3030303030303003

I can see in your script that it’s getting the houses inside a player’s character game.Workspace[Player.Name]:GetDescendants(). Are the houses supposed to be directly in the Workspace, or there are multiples in a player’s character? I am a bit confused about that.

You might need to create a separate folder for houses Screen Shot 2563-05-16 at 16.39.38

Not getting a model inside player’s character.

Its not erroring. I fixed it, I had to change it to GetChildren.