local RemoteEvent = game.ReplicatedStorage.ChangeTeam local Humans = "Dark blue" local Zombies = "Really red" game.Players.PlayerAdded:Connect(function(player) player.CharacterAdded:Connect(function(character) character:WaitForChild("Humanoid").Died:Connect(function() print(player.Team.Name) if player.Team.Name == "Blue" then RemoteEvent:FireServer(BrickColor.new(Zombies)) else RemoteEvent:FireServer(BrickColor.new(Humans)) wait(0.5) end end) end) end)
This is inside a script. The point is that when a player dies it changes to an opposite team , in this case blue to red , vice versa.
When I die the output says this "FireServer can only be called from the client".
Local Script
local Players = game:GetService("Players") local LocalPlayer = Players.LocalPlayer local Character = LocalPlayer.Character or LocalPlayer.CharacterAdded:wait() local ReplicatedStorage = game:GetService("ReplicatedStorage") local TeamChangeRemote = ReplicatedStorage.TeamChange Character:WaitForChild("Humanoid").Died:Connect(function() if LocalPlayer.Team.Name == "Humans" then TeamChangeRemote:FireServer('zombie') else TeamChangeRemote:FireServer('human') end end)
Server Script
local Players = game:GetService("Players") local ReplicatedStorage = game:GetService("ReplicatedStorage") local Teams = game:GetService("Teams") local TeamChangeRemote = ReplicatedStorage.TeamChange TeamChangeRemote.OnServerEvent:Connect(function(Player, TeamName) for _,TeamEntitys in next, Teams:GetChildren() do if (TeamEntitys.Name:lower()):find(TeamName:lower()) then Player.Team = TeamEntitys end end return nil end)
Instructions
I hope this answers your needs.
Hey! :FireServer cant be used on a server script. :FireServer fires a remote event from the client to the server. Since this script is in a server, you can take the code that is in the remote event from your server script, or you can make a function above the PlayerAdded event, and then fire that function in the if statment. Hope this helped!