So I wanna change the Adornee of my BillboardGui when I touch a brick but it doesn't work.

Here's my localscript(It's parented to the BIllboardGui that is inside the StarterGui):

local Player = game.Players.LocalPlayer
local PlayerGui = Player:WaitForChild("PlayerGui")
local InteractGui = game.Workspace:WaitForChild("InteractGui")
local Radius = InteractGui:WaitForChild("Radius")
local BillboardGuiHolder = game.Workspace:WaitForChild("BillboardGuiHolder")

script.Parent.Adornee = BillboardGuiHolder

local value = 0
 
Radius.Touched:connect(function(p)
    value = value+1
    script.Parent.TouchEnded:wait()
    wait(.35)
    value = value-1
end)
 
while wait() do
    if value > 0 then
        script.Parent.Adornee = InteractGui
    else
        script.Parent.Adornee = BillboardGuiHolder
    end
end

Can someone tell me what I'm doing wrong?

2 comments

0

Create an IntValue (Child of BillboardGui), Take advantage of 'Changed' event which is more efficient than leaving a loop all the time.

0

is the game FE?