Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

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

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

✓ Accepted answer

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

1 comment

0

thanks this helps a lot

This discussion is preserved as it was. New answers, comments, and votes are closed.