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

Why is the mouse clicking 2 guis?

Asked by 4 years ago

Hey, I've posted this on DevForums, I'm just reposting it here bc devforums is inactive.

So, I made a guis mode for my aim training game (for mobile users) and when I click a target, it clicks the target and clicks the background (which you are not supposed to click). Can somebody possibly tell me why this is happening? I tried to increase the ZIndex for the target gui, still doesn't work. Heres the code:

01game.ReplicatedStorage.OnClick.Event:Connect(function(gui)
02        if started then
03            totalParts += 1
04            gui:Destroy()
05            script.Parent.MainGui.Hit:Play()
06            local x, y = math.random(1, 9), math.random(1, 9)
07            print(x / 10, y / 10)
08            points += 20
09            accuracy += 1
10            displayPoints()
11            displayAccuracy()
12            createNewPart(UDim2.new(x / 10, 0, y / 10, 0)) -- Creates a new gui
13        end
14    end)
15 
View all 27 lines...

Hope you can help ._.

0
How is the SurfaceGUI set up (Assuming it's a SurfaceGUI) squidiskool 208 — 4y
0
It's a ScreenGUI, it's 2D, and the target is an imagebutton (I use MouseButton1Click to click it) and the background is a frame, so I use InputEnded. DragonSpawner12 61 — 4y
0
What is "Holder"? squidiskool 208 — 4y
0
The frame DragonSpawner12 61 — 4y
View all comments (13 more)
0
Also, the target is a child of "Holder" DragonSpawner12 61 — 4y
0
What's started? squidiskool 208 — 4y
0
started is changed to true when the game started. It changes to false when the game ends DragonSpawner12 61 — 4y
0
Well, is the frame the same size and position as the imagebutton? An image button is always rectangular, no matter the shape of it. squidiskool 208 — 4y
0
The imagebutton's size is 0.1,0,0.1,0, when the frame's size is 1,0,1,0. I set a random position to the image button. DragonSpawner12 61 — 4y
0
The frame size covers the whole screen. squidiskool 208 — 4y
0
Yes DragonSpawner12 61 — 4y
0
Well I'm not that experienced with guis so I can't really help you, sorry squidiskool 208 — 4y
0
Oh. DragonSpawner12 61 — 4y
0
Maybe try using ZIndex? aurich98 86 — 4y
0
I said that in the post, it didn't work DragonSpawner12 61 — 4y
0
You’re using InputEnded on the frame, not the ImageButton OhManXDXD 445 — 4y
0
I'm doing that because I want to check if the player didn't or did press the button. If they press the frame, then I'm not going to give a point. If they press the imagebutton, I am. DragonSpawner12 61 — 4y

Answer this question