Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

Why doesn't the descendants of my spectate UI update?

For whatever reason, the health of the player that was added to the spectate list doesn't update, nor will the button pressed attach the players camera.

-- Handled from the client

function getChar(Plr)
	local char = game.Workspace:FindFirstChild(Plr.Name)
	if char then return char end
end

function AttachCam(Plr)
	local char = getChar(Plr)
	game.Workspace.CurrentCamera.CameraSubject = char.Humanoid
end

game.Teams.Alive.PlayerAdded:Connect(function(player)
	local List = script.Parent.GameUI.Back.SpecBack.ListBack.List
	
	local Label = game.ReplicatedStorage.GuiStorage.Spec:Clone()
	Label.Name = player.Name
	Label.Lbl.Text = player.Name
	Label.Lbl.Shadow.Text = player.Name
	
	local char = getChar(player)
	
	local bar = Label:WaitForChild("Bar")
	bar.Size = UDim2.new(char.Humanoid.Health / char.Humanoid.MaxHealth, 0, 1, 0)
	
	player.Character.Humanoid.HealthChanged:Connect(function()
		bar.Size = UDim2.new(char.Humanoid.Health / char.Humanoid.MaxHealth, 0, 1, 0)
	end)	
	
	Label.Parent = List
	
	script.Parent.GameUI.Back.SpecBack.ListBack.List.CanvasSize = UDim2.new(1, 0, 0, 5 + (#List:GetChildren() * 35))

	Label.MouseButton1Click:Connect(function()
		AttachCam(game.Players:FindFirstChild(Label.Name))
		script.Parent.GameUI.Back.ExitSpec.Visible = true
	end)
end)

game.Teams.Alive.PlayerRemoved:Connect(function(player)
	local fetchLabel = script.Parent.GameUI.Back.SpecBack.ListBack.List:FindFirstChild(player.Name)
	if fetchLabel then
		fetchLabel:Destroy()
	end
end)

What the button looks like: https://gyazo.com/99ee14a6646fef4d8fddd05ffd00bdbe

1 answer

I suggest tweening the bar if this is a custom bar,

script.parent.TweenPosition(Udim2.new(x,x,y,y), blah blah

This discussion is preserved as it was. New answers, comments, and votes are closed.