You mean like:
local enabledSkills = {
"Cooking",
"Eating",
"Cats",
}
local function CanUseSkill(skillName)
return table.find(enabledSkills, skillName)
end
CanUseSkill("Cooking")
CanUseSkill("WideSteal")
If CanUseSkill("Cooking") then
print(true)
end
Basically, table.find in this case, checks if value with specific value is in the table, if it is then it will return the index of the value in that table, otherwise it will return nil so if the skill "Cooking" was found, it returned 1 as it is the index of the skill in the table while "WideSteal" is not in the table so the table.find returned nil. Means you can't do If CanUseSkill("Cooking") == true then but you can do If CanUseSkill("Cooking") == nil then (check if it is not in the table) or If CanUseSkill("Cooking") then (check if it is in the table)
You could also use pairs loop for that, it could have some cons in specific situations.
Here is roblox documentation about tables where it explains table.find.
2 comments
Thanks a lot! That will probably work, however how would I then go about disabling the localscripts for a specific player? My localscripts are in StarterPlayerScripts and is it even possible to access them? I would need the playe to do that too... But I guess it could work with a remoteevent?
Of course you could, you can also do: yourPlayer.PlayerScripts.YourScript.Disabled = true