How would I be able to make it so whenever a person guesses it, everyone else’s events disconnect so .Chatted won’t be running anymore?
for _,player in pairs(participantTeam:GetPlayers()) do
event = player.Chatted:connect(function(msg)
if msg:lower() == answer then
playerWinner = player
event:Disconnect() -- ??
end
end)
end
--store active connections inside an array
local connections = {}
for _,player in pairs(participantTeam:GetPlayers()) do
event = player.Chatted:connect(function(msg)
if msg:lower() == answer then
playerWinner = player
--loop through each connection and disconnect it
for index, connection in pairs(connections) do
connection:Disconnect()
table.remove(connections, index)
end
end
end)
--after the connection is created, insert it in the array
table.insert(connections, event)
end