I want a RemoteEvent to be fired to the server if a player who is on the Bright red team dies. The issue here is that, the RemoteEvent is only firing to the client who is on the Bright red team, and not every player. My code looks like this
local player = script.Parent.Parent
repeat wait() until player.Character ~= nil
local character = player.Character
local humanoid = character.Humanoid
local repStorage = game:GetService("ReplicatedStorage")
local event = repStorage:WaitForChild("RedDead")
print('Checking if the boss dies')
humanoid.Died:connect(function(Died)
if player.TeamColor == BrickColor.new('Bright red') then
print('Player on red team died')
event:FireServer()
end
end)
EDIT: Figured it out, I needed an for i, v in pairs do statement, like so
local player = script.Parent.Parent
repeat wait() until player.Character ~= nil
local character = player.Character
local humanoid = character.Humanoid
local repStorage = game:GetService("ReplicatedStorage")
local event = repStorage:WaitForChild("RedDead")
print('Checking if the boss dies')
humanoid.Died:connect(function(Died)
for i, v in pairs(game.Players:GetChildren()) do
if v.TeamColor == BrickColor.new('Bright red') then
print('Player on red team died')
event:FireServer()
end
end
end)
