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.
0

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

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 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 = UDim2.new(0,Xpos,0,Ypos)
--Here
else master.Visible = false
end
end
end)
end

sign.ClickDetector.MouseHoverEnter:Connect(display_master)


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...

0
I can give you a hint: UserInputService MooMooThalahlah 421 — 1y
0
aahhh very cleaver, I'll have a look into it in a few minutes :) AlexTheCreator 53 — 1y
0
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