Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Why wont it print "Joined Match!" when i have converted both values to a number?

Asked by 3 years ago

So i wanna make a script where players can join matches with a code. Here is the script:

script.Parent.MouseButton1Click:Connect(function()


    for _,v in pairs(game.Workspace:GetChildren()) do
        if v.ClassName == "Folder" then
            for _,matches in pairs(v:GetChildren()) do
                if matches.ClassName == "Folder" then
                    for _,code in pairs(matches:GetChildren())do
                        if code.Name== "MatchCode" then
                            local number = tostring(script.Parent.Parent.Parent.CodeInput.Text)--CodeInput is the textbox where players put in the code
                            local Ncode= tostring(code.Value)
                            if number == Ncode then

                            print("Joined Match!")

                            else

                                    print("Invalid Code")
                            end


                        end
                    end
                end
                end
        end
    end


end)

Whenever i put in the Code input box the same value as the match code, it still prints invalid code. Someone please help!

0
Whats the line 9 for? TrossCraft -13 — 3y
0
to find the match code string value COOLGUY16T 37 — 3y
0
Can you try to print the numer print(number) and print the Ncode print(Ncode) TrossCraft -13 — 3y
0
When i do that number equals nothing??? COOLGUY16T 37 — 3y

1 answer

Log in to vote
0
Answered by 3 years ago

I think its not necessary to use the "ToString" in your script, Just change line 10 to

local CodeInput = script.Parent.Parent.Parent.CodeInput
local number = CodeInput.Text

And change Line 11 to

local Ncode= code.Value

I hope it works! :D

0
Still doesn't work... COOLGUY16T 37 — 3y
Ad

Answer this question