I very small knowledge on how to use Tables. From what I have seen in other scripts, this seems what it would look like, i'm not sure. Could someone tell me if this is right, and if not, tell me what to change?
allies=15124, 23235, 23523, 1234, 5235 while true do TDS=game.Workspace.TDS hos=game.Workspace.hos wait() game.Players.PlayerAdded:connect(function(plr) if plr:IsInGroup(374223) then TDS.Value=TDS.Value+1 elseif plr:IsInGroup(allies) then else hos.Value=hos.Value+1 end end) end
IsInGroup
requires a number, while allies
is a list of numbers, so we can't give it allies
directly.
We consider a player to be an ally if they are in the first ally group, or the second, or third, and so on.
Therefore we loop over the list of allies and test if they are in the first ally
, or
the second ally
, or
the third ally
:
local allied = false; for _, ally in ipairs(allies) do allied = allied or plr:IsInGroup( ally ); end -- `allied` is a boolean; `allied` is true if `plr` is -- in one of the groups listed in `allies`
For those unfamiliar with this type of for
loop, the following snippet is equivalent to the preceding snippet:
local allied = false; for _ = 1, #allies do local ally = allies[_]; allied = allied or plr:IsInGroup( ally ); end
This is how you should use the table, it has index which is for example allies , it has numbers it will read and do the script of all of those.
for i,v in pairs(allies) do if plr:IsInGroup(allies) then -- your script o3o
-- Fixed it xD