How do you make a billboard GUI local to a player

How would I be able to make it so when the user approaches the part that the billboard GUI is parented to it would run a tween action and would pop up but only to the client side that’s close enough to it, here’s my current script.

Local Script

local EggGUI = script.EggGUI

local location = game.Workspace.EggDispenser1["Egg Dispenser"].OuterEgg

local Container = game.Workspace.EggDispenser1.EggArea

local Zone = require(game.ReplicatedStorage.Zone)

local zone = Zone.new(Container)

print("Script Loaded")
zone.playerEntered:Connect(function(player)
	print("In")
	EggGUI.Enabled = true
	EggGUI.Parent = location
end)

zone.playerExited:Connect(function(player)
	print("Out")
	EggGUI.Enabled = false
end)

I have not added a tween service yet right now I’m focused on getting the client side problem fixed first.

Here there’s a container in-which if the player starts walking inside in it triggers the function playerEntered (this is a API I found on the DevForum somewhere). What the problem is, is when the player triggers the function the transparency goes back to 0 but it shows it to every player on the server.

If an example is needed I’m trying to get something like how Pet Simulators Egg Incubator pops up with a billboard GUI when a user gets close enough or enters a container and only shows for the client side.

Any feedback is appreciated thanks.

I suggest you to use Magnitude
Example:

(Make sure that your Container is a part!)

local EggGUI = script.EggGUI
local location = game.Workspace.EggDispenser1["Egg Dispenser"].OuterEgg
local Container = game.Workspace.EggDispenser1.EggArea
local studs = 10 -- The studs from the player to part increase to make gui visible from long distance

local function getDistance(part)
	local player = game.Players.LocalPlayer
	local char = player.Character
	local humanoidRoot = char.HumanoidRootPart or char:WaitForChild("HumanoidRootPart") or char:FindFirstChild("HumanoidRootPart")
	
	local distance = (part.Position-humanoidRoot.Position)
	return distance.Magnitude
end

game["Run Service"].RenderStepped:Connect(function()
	if getDistance(Container) <= studs then
		EggGUI.Enabled = true
		EggGUI.Parent = location
	else
		EggGUI.Enabled = false
	end
end)

It works perfectly, but can I have a brief explanation on why the API I used in my script didn’t work instead but your one has? (Learning from my mistakes).

Well first of all its not an API, you can call it a module :grinning_face_with_smiling_eyes:
So I think you are using a zone module which checks if player enters/leaves the PART

so like you have a part, the script you used gets the player that ENTERS or LEAVES your part, it can be used as different sound regions or as safezone.

WHILE

Magnitude Is used to check the distance (in studs) between 2 parts.
Example

local person1 = workspace.Person1 -- Both of them are parts.
local person2 = workspace.Person2 -- Lets think they are a person

local distance = person1.Position - person2.Position -- Gets the position between those 2 person.
local studs = distance.Magnitude -- Returns the distance in studs

Now you got the studs, you can check by using if statement.

if studs <= 20 then -- checks if person 1 is in 20 or less studs than person 2
   -- Do stuff
end

I understand the difference but what I don’t understand is how they both run the same code when the condition is met but don’t output the same result (basically how magnitude works and shows client side only but the playerEntered script does not).