Help with my code gui

Hello!
I’m trying to make a code gui where a player has to enter a code that is displayed on a heart rate machine

Everything should be working, but for some reason it still doesn’t

Here is the layout:

this is the panel -

here is where the code is stored -
image

the lua inside the “enter” textbutton -

local code = script.Parent.Parent.Code.Value

script.Parent.MouseButton1Click:Connect(function()
	if script.Parent.Text == code then
		script.Parent.Text = "Success"
	else
		script.Parent.Text = "Incorrect"
	end
end)

No matter what happens, it still says incorrect.

as you can see, the code does appear in the value, but it still doesn’t work

pls help lol

You are returning the value.

You can only Assign the Variable to the Instance, not the Value itself for it to work.

Try this:

local code = script.Parent.Parent.Code -- Instance

script.Parent.MouseButton1Click:Connect(function()
	if script.Parent.Text == code.Value then -- Value
		script.Parent.Text = "Success"
	else
		script.Parent.Text = "Incorrect"
	end
end)

I will try this, but in all other cases when I use values i always get the value of the value and it works for me - is it different in this case and why? Edit: I’m getting the same error

Actually, maybe try this?
I think since the Text is a string and not a number, thats the reason

local code = script.Parent.Parent.Code

script.Parent.MouseButton1Click:Connect(function()
	if tonumber(script.Parent.Text) == code.Value then
		script.Parent.Text = "Success"
	else
		script.Parent.Text = "Incorrect"
	end
end)

I’m sorry, I’m such and idiot. I was referencing the wrong thing the whole time. Thanks for your time, I’ll mark you as the solution. :slight_smile:

1 Like

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