I have a script that's supposed to get password input from a remote event (works fine) and if the password matches one from the table it gets the place id of the password and returns a value true or false depending on if the password was right.
Example:
re:FireClient(plr,false) -- password wasn't correct
re:FireClient(plr,true) -- password was correct
Any help is appreciated!
My code is here:
local TpService = game:GetService("TeleportService")
local re = game.ReplicatedStorage["HelloScripters!!"]
local passwords = {}
-- Passwords --
passwords["12 15 05"] = {}
passwords["15 15 25"] = {}
-- Password place IDs --
passwords["12 15 05"].id = "8346845291"
passwords["15 15 25"].id = "2548213281"
print(passwords)
local function tpTo(ID,PLAYER)
TpService:Teleport(ID,PLAYER)
end
re.OnServerEvent:Connect(function(plr,password)
print("Received password input by "..plr.Name..". Entered password: "..password)
local success = false
local brr
local thing = table.find(passwords,password) -- doesnt find it and returns nill even if the password exists
print(thing)
--[[
for i,thing in pairs(passwords) do
if thing.Name == password then
brr = thing
end
end
]]
if brr then
local id = brr.id
if id then
success = true
print("Info: Password & ID found! Password: "..brr.." ID: "..id)
else
print("DANGER: No ID for password: "..brr)
end
else
print("Warning: Incorrect or non-existing password.")
end
--[[
for i, bruh in ipairs(passwords) do
if bruh == password then
success = true
print(bruh)
print(bruh.id)
re:FireClient(plr,true)
tpTo(bruh.id,plr)
end
end
]]
if success == false then
re:FireClient(plr,false)
else
re:FindClient(plr,true)
end
end)

4 comments
there is a value of "12 15 05" and "15 15 25" heres the table: https://imgur.com/a/xO9MREv
there is a value of "12 15 05" and "15 15 25" heres the table: https://imgur.com/a/xO9MREv
ok nvm it works idk why lol but thanks
Again, they aren't the values, they are the indexes. If you look at a table, every value has an index, whether you are assigning one yourself or it's automatically assigned to a number. In this case, you are setting your own index of "12 15 05" and setting the value of it to the table which has "id" stored inside of.