If then not functioning

I was making this script that checks a part if it says a certain word to see if its the word its looking for

--locals
local ClickDetector = script.Parent.ClickDetector
--actual script
	local function onClick()
	if workspace.sign.SurfaceGui.TextBox.Text = "9"
then
		workspace.signa.SurfaceGui.TextBox.Text = "nice job"
		else
		workspace.signa.SurfaceGui.TextBox.Text = "bruh"
	end
end
ClickDetector.MouseClick:Connect(onClick)

When I test it, it doesn’t work. Whats wrong?

When checking for equality, use the double equals sign ==
so your if statement should look something like this instead:

if workspace.sign.SurfaceGui.TextBox.Text == "9"

the rest of your code from what I see should work properly, assuming you’ve got everything indexed properly

2 Likes