Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

How do you put an ImageButton into the Topbar, or the CoreGui?

Asked by 5 years ago

I understand how to disable stuff into the coregui but I dont know if I should make instances or if theres a way I can put them into the topbar.

1 answer

Log in to vote
1
Answered by
DanzLua 2879 Moderation Voter Community Moderator
5 years ago

So normally there'd be no way to check for click events when a button is behind the topbar and roblox has no intention of adding this as a feature. But there is a hacky way to get around this.

What we do is whenever the player has clicked somewhere on the screen, we check the click's position to see if it is inside the button behind the topbar!

--variables
local uis = game:GetService("UserInputService")
local mouse = game.Players.LocalPlayer:GetMouse()

--button (change this to your button)
local button=script.Parent.ScreenGui.TextButton

uis.InputEnded:Connect(function(input)
    --checks to see if the the mouse is inside the button's boundaries
    --if so then
    if input.UserInputType == Enum.UserInputType.MouseButton1 then
        if mouse.X>button.AbsolutePosition.X and mouse.X<button.AbsolutePosition.X+button.AbsoluteSize.X
            and mouse.Y>button.AbsolutePosition.Y and mouse.Y<button.AbsolutePosition.Y+button.AbsoluteSize.Y then
            print("clicked button")
        end
    end
end)

thus we get this

Wiki on UserInputService Wiki on AbsolutePosition

0
thanks this helps a lot ReallyUnikatni 68 — 5y
Ad

Answer this question