It wont detect though it is right

Hello People!!

So i was doing a script about a Gui that Identify’s a certain code and like that send trough a Remote Event to enable a Door so that the player can go trough the other side…

The problem fellas is that the :


Ain’t working somehow, what is quite strange because it always worked on other types of script.

I tried looking here on da page but nothing doesn’t quite guide me up, aswell i changed the script and tested alot to see what was happening.

Also Here is the script!

local ServerStorage = game:GetService("ServerStorage")
local TextPad = script.Parent.Parent:WaitForChild("TextPad")
local RemoteEvent = ServerStorage:FindFirstChild("EnableDoor")
local Code = script.Parent.Parent.Parent.Code.Value
local StringMatch = string.match(TextPad.Text, Code)

local function DetectCode(Door)
	if StringMatch then
	elseif not StringMatch then
		print("You had only a job, and it was to get the code trough the phone")


In advance, some cookies! :cookie: :cookie: :cookie:

1 Like

If you are matching the code to player input, why aren’t you using the == operator and using string.match?

I’m gonna try looking into that

@Kostiskat What you mean with String Matching?

Sure it does, it prints on the output the message if it doesn’t string matches

StringMatch is permanently false, because you only check it once and it returns false. The stored value is now false.

change the condition to

if string.match(TextPad.Text, Code) then

This way it will check everytime and not use a stored value from the beginning.

1 Like

Thank you! Actually now checking by It worked before when i changed a bit of the script to something like that but I din’t notice because i outputted a error of the Remote Event. / And wow you just gained a follower cuz that’s the language of the Gods :sunglasses:

1 Like