Billboard GUI's Y position changes for literally no reason

Howdy. I have an issue consider Billboard gui’s. When leaving the max range and returning it seems to change it’s position for what looks like no reason. I’ve tried setting the Offset to it’s original position within the workspace, when it is enabled although that doesn’t seem to fix my issue.

Here’s my script.

local part = game.Workspace.Items["Green Block"] -- the part I want to attach the Billboard GUI to
local minrange = 5
local range = 25 -- the range of the proximity prompt
local billboard = game.ReplicatedStorage:WaitForChild("InteractionAvailableUI"):Clone() -- create the Billboard GUI
billboard.Parent = part -- attach it to the part
billboard.Enabled = false -- set it to not visible by default
billboard.Adornee = part
print("script is working")

local function checkDistance(player)
	print("checking position")
	local character = player.Character
	if not character then -- wait for the character to load
		return
	end
	local humanoidRootPart = character.HumanoidRootPart
	if not humanoidRootPart then -- wait for the HumanoidRootPart to load
		return
	end
	local distance = (part.Position - humanoidRootPart.Position).Magnitude
	if distance >= minrange then -- if the player is inside the range of the proximity prompt
		if not billboard.Enabled then -- if the Billboard GUI is not already enabled
			billboard.Enabled = true -- enable the Billboard GUI
			billboard.Adornee = part
			print("enabled")
		end
	else -- if the player is outside the range of the proximity prompt
		if billboard.Enabled then -- if the Billboard GUI is not already disabled
			billboard.Enabled = false -- disable the Billboard GUI
			print("disabled")
		end
	end
end

local player = game.Players.LocalPlayer

while true do
	wait(.05)
	checkDistance(player)
end

Here’s a video showcasing my problem.

Also, if anyone found a more practical way to check the player’s distance from the ui that would be greatly appriciated. Thanks for the help!

I can think of two things to try:

  1. billboard.CFrame = part.CFrame
  2. Make sure that Part is Anchored (and billboard is Anchored)

billboardhui’s cannot be unanchored. And I don’t believe that’s how billboard gui’s work. Thanks for the suggestion, however!

Seems like it was a loading issue. After I switched to another technique that didnt involve loops it seems to be working (for the most part) fine. I can’t be sure though, so if anyone does- Please let me know!

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