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

Identifying if the player clicked on the upper part of the screen?

Hello, fellow scripters; I made a script(complicated to explain) I was trying to do an experiment or [how would it work] So i did the 'Button1Down' which whenever you click on any part of your screen it would print something. Normally:

local player = game.Players.LocalPlayer
local mouse = player:GetMouse()
repeat wait() until player

function button()
print("Down")
end
mouse.Button1Down:connect(button)

Similar to that: The thing i was willing to find out is [how] From the center of your screen, how will i let my output print 'hi' whenever i click the upper part of the screen instead of clicking "anywhere" on my screen. [Only the upper part; starting from the center]

I would appreciate your help, i can't find the proper term for it and was not able to find any results from google from my own words.

1 comment

0

make an invisible button

1 answer

✓ Accepted answer

Good question. Theres actually two ways to do this, one with math and other using GUIs (as NathanTheDeveloper stated).

Math method Simply check if the mouses' Y Value is below half of the viewport size for upper side, or above half for lower side. Essentially, what i mean in 1 simple line:

if mouse.Y < (mouse.ViewSizeY / 2) then /*code*/ end

mouse.ViewSizeY expresses the viewport size - the window screen.

GUI method While this is probably easy to figure out yourself, I'll give you a little hint. Make a GUI Button in the upper half of the screen. This is a complicated workaround and not worth the use; I'd recommend the math method ;).

1 comment

0

Hey, Intern33t thanks for the respond, With your 'Math method' it worked perfectly!

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