This script is supposed to print "announced" when there is more then 1 player that is not in the defense group in the game. I'm not sure where the script just stops working, ROBLOX does not give me any errors in output. The person I am testing it with is not in the group that it is set to.
-- Settings
local MinRaiders = 1 -- Number of raiders to trigger defence notification
local DefenceGroup = 4831556 -- Group that is marked as defenders, anyone not in this group and on raider team will count to raider numbers.
local RaidTeam = 'Lobby' -- Name of the raider team
-- Main Script
local Players = game:GetService('Players')
local Teams = game:GetService('Teams')
local debounce = false
function PostAnnouncement()
print("Announced")
end
Players.PlayerAdded:Connect(function(Player)
Player:GetPropertyChangedSignal('Team'):Connect(function()
local Count = 0
if debounce == false then
local CountLoop = Teams:WaitForChild(RaidTeam):GetPlayers()
Count = 0
for i,v in pairs(CountLoop) do
local GroupRank = Player:GetRankInGroup(DefenceGroup);
if GroupRank == 0 then
Count = Count + 1
end
end
if Count >= MinRaiders then
debounce = true
local Success = PostAnnouncement()
debounce = false
end
end
end)
end)
