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

Numbers not matching with randomized code?

Asked by
yoshi8080 445 Moderation Voter
5 years ago
Edited 5 years ago

What I plan is to have a random code thats generated and I have pumpkins set that can be changed to whatever that code is.

However, when the code matches, it doesn't return the code as matching.

local TheCode = math.random(1,9)..math.random(1,9)..math.random(1,9)..math.random(1,9)..math.random(1,9)..math.random(1,9)..math.random(1,9)..math.random(1,9)..math.random(1,9)

for i,v in pairs(workspace.Pumpkins:GetChildren()) do
    -- Finds certain Pumpkin with Number for example (Pumpkin1, Pumpkin2, etc.) and matches each one pairing with the digit placement of the code, shown as "TheCode" variable

while (workspace.Pumpkins:FindFirstChild('Pumpkin'..string.match(v.Name,"%d+")).Code.Value) == (string.sub(TheCode, (string.match(v.Name,"%d+")) , (string.match(v.Name,"%d+")))) do
    print('code matched')
        end
    end
end

Answer this question