New: Nitro Boost our Discord server and receive full donation perks here on the website! Join the Scripting Helpers Discord Server to learn more! You can also Support on Patreon as always.
Still have questions? Join our Discord server and get real time help.
Log in to vote

How can I detect clicks while using a mousehoverenter function? (GUI shop issue)

Asked by 1 year ago

Hi guys,

I'm trying to make a system of buying a plot of land by using a screen gui which appears when the players mouse enters the boundary of a sign:

local sign = script.Parent

local function display_master(player)
    local mouse = player:GetMouse()

    local screengui = player:FindFirstChild("PlayerGui"):WaitForChild("buy_house")
        local master = screengui:FindFirstChild("m_frame")

    game:GetService("RunService").RenderStepped:connect( function()
        local Xpos = mouse.X
        local Ypos = mouse.Y

        if mouse.Target then
            if mouse.Target == sign
                then master.Visible = true
                master.Position =,Xpos,0,Ypos)
            else master.Visible = false


which works fine... however I want to make it so that when the player clicks (showing intention to buy) the current gui (which is displaying cost information) will disappear and another gui (pretty much saying "are you sure") will appear in it's place... I've tied this by using sign.ClickDetector:MouseClick:Connect() where the comment "here" is, but i don't think this is the best idea (I've also had issues with events firing more than once if the mouse leaves and then re-enters the frame. Is there a way to stop this from happening?)

Does anybody know how I should go about creating this system or how I should be detecting clicks?

Thanks for the help guys, I'm pretty new to this so sorry if im not clearly explaining my problem...

I can give you a hint: UserInputService MooMooThalahlah 421 — 1y
aahhh very cleaver, I'll have a look into it in a few minutes :) AlexTheCreator 53 — 1y
I'm currently using a script within a part to call the Gui, will a local script in the same plae funciton as intended or should I have the local scripts omsewhere within the player? AlexTheCreator 53 — 1y

Answer this question