I’m making a tag script where players can choose their own tags and I made it like this
RemoteEvent.OnServerEvent:Connect(function(Player,Tag,Command)
if Command == "GetEquipped" then
TagList:GetEquippedTags(Player.Name)
elseif Command == "Equip" then
TagList:EquipTag(Player.Name,Tag)
elseif Command == "Unequip" then
TagList:UnequipTag(Player.Name,Tag)
elseif Command == "Give" then
TagList:GiveTag(Player.Name,Tag)
elseif Command == "Remove" then
TagList:RemoveTag(Player.Name,Tag)
end
end
However I’m pretty sure this is bad but I have no idea how to do this in a more cleaner way, any idea how?
it just uses a custom error handler, if you really wanted to, you can use pcall
local success = pcall(function() -- not xpcall
t[Command](Player.Name, Tag) -- Fires function by string name
end)
if not success then
warn"Command Does not Exist!"
end