MouseButton1Click/Down/Up Triggered by doing nothing

Hi, I want to make a math problem GUI, where you answer math problems.

Issue is that when I join the game, the GUI script immediately detects mousebutton1 being clicked, without doing anything.

Heres the code:

local mathproblem1 = math.random(-50,50)
local mathproblem2 = math.random(-100,100)
local submitbutton = script.Parent.Parent.Submit
local mathproblemtext = script.Parent.MathProblem
local frame = script.Parent.Parent.Frame
local maxtime = script.Parent.MaxTime
local textbox = script.Parent.Parent.TextBox
local soundeffects = script.Parent.SoundEffects
local Players = game:GetService("Players")
local LocalPlayer = Players.LocalPlayer
local LocalCharacter = LocalPlayer.Character or LocalPlayer.CharacterAdded:Wait()
local LocalHumanoid = LocalCharacter:WaitForChild("Humanoid")

mathproblemtext.Text = "What is "..mathproblem1.." + "..mathproblem2.."?"
frame.Visible = true
textbox.Visible = true
submitbutton.Visible = true
maxtime.LocalScript.Enabled = true
if submitbutton.MouseButton1Up then
	if textbox.Text == mathproblem1 + mathproblem2 then
	elseif textbox.Text ~= mathproblem1 + mathproblem2 then

Here’s the explorer:

Here’s the issue:
(This is when I wanted to see what was going on with the GUI, note this happens when I just joined the server.)

Any help would be appreciated, thank you!

That isn’t how you use events. You need to connect them

submitButton.MouseButton1Up:Connect(function(mouseX, mouseY) -- You can call these whatever you want
    print("Button unpressed")

I’ll leave the explaining for someone else because I’m not very good at explaining things and I might make things worse.

1 Like

Thanks, I forgot that existed
30 corn on the cob

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.