Height Bar GUI show all players

Perfect thanks again! add my alt so I can add you to team create: Prizm_Dev

Added.

1 Like

Alright place name is Height Bar GUI, Loaded in the exact gui from other game with a stair case to show height.

It’s because you set the totalHeight as a negative number, and I was referencing ImageLabel, not newImage. There was also some minor math problems. Fixed it though.

Code:

--//Services
local Players = game:GetService("Players")
local RunService = game:GetService("RunService")

--//Variables
local LocalPlayer = Players.LocalPlayer
local Frame = script.Parent
local ImageLabel = script.ImageLabel

--//Controls
local ThumbnailType = Enum.ThumbnailType.HeadShot
local ThumbnailSize = Enum.ThumbnailSize.Size48x48

--//Functions
local function OnPlayerAdded(player)
	local newImage = ImageLabel:Clone()
	newImage.Name = player.UserId
	newImage.Image = Players:GetUserThumbnailAsync(player.UserId, ThumbnailType, ThumbnailSize)
	newImage.Parent = Frame

	local HumanoidRootPart = nil

	local function OnCharacterAdded(character)
		HumanoidRootPart = character:WaitForChild("HumanoidRootPart", 5)

		local updateConnection = nil

		updateConnection = RunService.Heartbeat:Connect(function()
			if not HumanoidRootPart then
				updateConnection:Disconnect()

				return
			end
			
			local currentHeight = math.ceil(HumanoidRootPart.Position.Y)
			local highestPoint = 765.125
			local ratio = currentHeight / highestPoint
			newImage.Position = UDim2.new(-0.25, 0, 1 - ratio, 0)
		end)
	end

	player.CharacterAdded:Connect(OnCharacterAdded)

	player.CharacterRemoving:Connect(function()
		HumanoidRootPart = nil
	end)
	
	if player.Character then
		OnCharacterAdded(player.Character)
	end
end

local function OnPlayerRemoving(player)
	local currentImage = Frame:FindFirstChild(player.UserId)

	if currentImage then
		currentImage:Destroy()
	end
end

Players.PlayerAdded:Connect(OnPlayerAdded)
Players.PlayerRemoving:Connect(OnPlayerRemoving)

for i, player in ipairs(Players:GetPlayers()) do
	task.spawn(OnPlayerAdded, player)
end
1 Like

Thank you so much!!! :grin:

1 Like

No problem, if you have any more questions, feel free to ask.

1 Like

Hey sorry to bother you but one more quick question if you have the time: I just changed the anchor point of the “ImageLabel” that shows the players avatar to (0.5, 0.5) so its in the middle of the bar inside like this:
image
But I don’t know how to configure the script/GUI. So at the beginning and end the image label is half way off the bar:
image
image
Is there an easy way to fix this?

Use math.clamp on the positioning of the ImageLabel.

1 Like

Works, but stays in the same place even when not at bottom and gets to top to early, Ill do some research. Thanks for the help
image
(edit: I figured it out, just had to make another frame inside the bar that was slightly smaller)

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