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
soundeffects.Correct:Play()
script.Parent.Parent.Parent.MathProblem1:Destroy()
elseif textbox.Text ~= mathproblem1 + mathproblem2 then
soundeffects.Wrong:Play()
LocalHumanoid:ChangeState(Enum.HumanoidStateType.Jumping)
script.Parent.Parent.Parent.MathProblem1:Destroy()
end
end
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!