i am using this code and chnaging if to elseif is makng error (i am not so stupid to change the 1. one)
function GiveHimPremisions(name,premisionLevel)
if premisionLevel==“owner” then
print(“owner”)
end
if premisionLevel==“co-owner” then
print(“co-owner”)
end
if premisionLevel==“head-admin” then
end
if premisionLevel=="admin" then
end
if premisionLevel=="top-moderator" then
end
if premisionLevel=="moderator" then
end
if premisionLevel=="comunity-moderator" then
end
if premisionLevel=="thrusted-player" then
end
if premisionLevel=="veteran-player" then
end
if premisionLevel=="new" then
end
end
This is how you use elseif and it’s way better than what you were doing.
if permisionLevel == "owner" then
print("Owner")
elseif perimsionLevel == "co-owner" then
print("co-owner")
elseif perimsionLevel == "head-admin" then
-- do stuff
else
--if they aren't any of these ranks then do this stuff
end
Lua doesn’t have a switch statement but you can still do something similar.
local Test = 1
local Cases = {
number = function() print("I'm a number") end
string = function() print("I'm a string") end
}
Cases[typeof(Test)]() --Prints "I'm a number"
like in my code when i want to use this for executing some code if the string = owner other code if it = co-owner and other code if none of this(i dont know how much you know swith, but like default case in swith in other languages)
local test = CFrame.new()
local function Switch(Test, Cases)
if Cases[Test] then
Cases[Test]()
else
Cases["Default"]()
end
end
Switch(typeof(Test), {
number = function()
print("I'm a number")
end,
string = function()
print("I'm a string")
end,
Default = function()
print("I'm not a number or a string")
end
}
)