UDim2 not working with Variables

Hello! I am currently scripting a player list GUI with team tabs.

Part of this process is scripting a frame to scale its height using UDim2 with variables depending on how many players there are in a team. The variable is a number value, the product of a cell’s height x the player count.

I have tried searching for other posts related to this, but I couldn’t find any. However, I tried to print (number * # of players) and it worked. UDim2 doesn’t seem to recognize this variable I’m making.

This is a LocalScript located in the frame.

while true do
	if game.Teams:FindFirstChild(script.Parent.Frame.TextLabel.Text) then
		local Team = game.Teams:FindFirstChild(script.Parent.Frame.TextLabel.Text)
		local TeamMembers = Team:GetPlayers()
		local teammembercount = tonumber(32*#TeamMembers)
		script.Parent.Size = UDim2.new(0, 180, 0, teammembercount)
	end
	wait(5)
end

Does anyone have any solutions or know what’s going on? Any help would be appreciated.

1 Like

Found the solution. I was only setting the size that fit the title slot, not including the space that could include players.