-- // Random
local CorrespondingReasons = {
[1] = "Detected HopperBins",
[3] = "Detected Character modifications",
[4] = "Detected Connections disconnected",
[5] = "Detected Workspace modifications",
[0] = "Disconnected" -- // Random disconnect reason...
-- adding more
}
How can I index this for a certain number like index for 5 and return "Detected Workspace modifications", and if what im trying to index does not exist than return
-- // Random
local CorrespondingReasons = {
[1] = "Detected HopperBins",
[3] = "Detected Character modifications",
[4] = "Detected Connections disconnected",
[5] = "Detected Workspace modifications",
[0] = "Disconnected" -- // Random disconnect reason...
-- adding more
}
local function getReason(n: number)
return CorrespondingReasons[n or 1] or ""
end
Yes, if no value was found in the table it will return an empty string and if no number was passed, it will return “Detected HopperBins” (index 1).