Hey, I currently need help with this piece of code that is currently in a local script inside of a ScreenGui's ImageButton in startergui I need help making this code compatible with a Billboardgui instead of a screengui.


local UIS = game:GetService("UserInputService") -- Service used to get the key pressed by a player
 
UIS.InputBegan:connect(function(input,gameProcessed)
    if input.UserInputType == Enum.UserInputType.Keyboard then -- Checks if the player uses a Keyboard
        if input.KeyCode == Enum.KeyCode.E then -- Checks if the player pressed the "Y" key
            if UIS:GetFocusedTextBox() == nil then -- Checks if the player is typing on a textbox like the chat... If not then...
                for i,v in pairs(game.Workspace.NPC:GetChildren()) do -- Finds all the children from the folder. In this case it will find all the NPCs
                    local mag = (v.UpperTorso.Position-game.Players.LocalPlayer.Character.HumanoidRootPart.Position).magnitude -- Makes a variable for the position between the character and the npc.
                    if mag <= 6 then -- If the magnitude is less than or equal to 10 studs then
                        --Effect XD
                        for i = 1,0.6,-0.05 do
                            wait()
                            script.Parent.ImageButton.ImageColor3 = Color3.new(i,i,i)
                        end
                        wait()
                        for i = 0.6,1,0.05 do
                            wait()
                            script.Parent.ImageButton.ImageColor3 = Color3.new(i,i,i)
                        end
                        --This effect is like when you pressed a button it will darken.
                        v.NPCTalk:FireServer()
                    end
                end
            end
        end
    end
end)
 
while wait() do
    script.Parent.Visible = false -- Makes it invisible on screen
    for i,v in pairs(game.Workspace.NPC:GetChildren()) do -- Finds all the children from the folder. In this case it will find all the NPCs
        local mag = (v.UpperTorso.Position-game.Players.LocalPlayer.Character.HumanoidRootPart.Position).magnitude -- Makes a variable for the position between the character and the npc.
        if mag <= 6 then -- If the magnitude is less than or equal to 10 studs then
            local WSP = game.Workspace.CurrentCamera:WorldToScreenPoint(v.UpperTorso.Position) -- The position of the NPC's UpperTorso
            script.Parent.Visible = true
            script.Parent.ImageButton.BorderSizePixel = 0
            script.Parent.Size = UDim2.new(598,WSP.X,356,WSP.Y)
            script.Parent.Position = UDim2.new(-0.03,WSP.X,-0.05,WSP.Y)
            script.Parent.TextLabel.Text = ""..v.Name -- Refreshes the text and puts the name of the npc
        end
end
end