Hey devs.
Im currently working on my genre, and we wanna make it so you can be only in one nation a time. I want it so if you are in one group and you join nothing happens but if you join and you re in two groups that are in the genre it kicks you. Now I was thinking I could just use playerAdded for this and see if hes in many groups but that would be long. Is there anyway I could do this quickly and neatly
The only way of doing this is using Player:IsInGroup(groupId)
(or GetRank/RoleInGroup but those are just extra for this)
Example of using this in a LocalScript
in StarterPlayerScripts
local plr = game:GetService("Players").LocalPlayer
local groups = {0,1,2,3} -- All the group ids
local inGroups = 0
for i,v in pairs(groups) do
if plr:IsInGroup(v) then
if inGroups >= 2 then plr:Kick("You can only be in one group at a time.") return end
inGroups = inGroups + 1
end
end
Just gonna point out: I haven’t tested this; however it SHOULD work.