Code GUI Doesn't Work

You can write your topic however you want, but you need to answer these questions:

  1. What do you want to achieve? Create a working Code GUI.

  2. What is the issue? Every time I put in the right code, it only comes up as incorrect

  3. What solutions have you tried so far? Using Youtube or use references other models from Toolbox, but none have worked.

Script:

script.Parent.ClickDetector.MouseClick:Connect(function(plr)
	if plr.PlayerGui:FindFirstChild("AnswerGui") then
	else
		local clone = script.Parent.AnswerGui:Clone()
		clone.Parent = plr.PlayerGui
		clone.Frame.Enter.MouseButton1Click:Connect(function()
			if clone.Frame.TextBox.Text == clone.Answer.Value then
				clone.Frame.TextBox.TextStrokeColor3 = Color3.new(0,255,0)
				clone.Frame.TextBox.Text = "CORRECT"
				wait(.5)
				clone:Destroy()
			else
				clone.Frame.TextBox.Text = "INCORRECT"
				clone.Frame.TextBox.TextStrokeColor3 = Color3.new(255,0,0)
				wait(.5)
				clone.Frame.TextBox.Text = ""
				clone.Frame.TextBox.TextStrokeColor3 = Color3.new(0,0,0)
			end
		end)
	end
end)

In this clip, I set the answer as “Hi”
image

https://i.gyazo.com/7bee935931bf4423281cab2900bcd812.gif

Picture of the entire thing
image

2 Likes

if this is in a normal script and not a localscript, that is your problem. textbox input cannot be read from server side.

2 Likes

Would just putting this script in a LocalScript make it work instead or do I need to make additional changes?

1 Like

No, other than setting the a new variable to game.Players.LocalPlayer.

When I click it the GUI doesn’t open for me now.

You should probably use a server script to open/close the GUI, and a local script for detecting the clicks inside the gui.

Also check if you made any mistakes when you set “Hi” as an answer, for example you could have put it lowercase, or accidentally put a space in the string.

Why don’t you put it in Starter Gui And make The Frame visible?