Changing a player's team

I’m making a team changer script, but it’s not working, here it is:

game.ReplicatedStorage.Events.Event.OnServerEvent:Connect(function(plr)
	plr.Character.Humanoid.Health = 0
	plr.Team = game.Teams.Visitante
end)

Also i have a localscript that triggers the event in ReplicatedStorage.

Any ideas why it’s not working?

3 Likes

Have you checked if the RemoteEvent connection actually ever happens?

Try changing the player’s team using

plr.TeamColor = game:GetService("Teams")["Visitante"].TeamColor

You can also respawn the character by doing:

plr:LoadCharacter()

so you won’t need to kill him and wait until respawn.

3 Likes

The part that reloads the character does work, but it still doesnt change the team.

So the RemoteEvent actually never errors? It just doesn’t team the player?

That’s a very strange result, are you sure there’s nothing else affecting the player’s team or the script itself?

I wrote and tested this script with a .Touched connection and it worked without any problems.
Script I’ve used:

local Team = "Nintendo"

script.Parent.Touched:Connect(function(h)
	local player = game.Players:GetPlayerFromCharacter(h.Parent)
	if player then
		player.Team = game:GetService("Teams")[Team] -- Team is "Nintendo"
	end
end)

Result:

4 Likes

Send the LocalScript and the location of the event, please.

1 Like

Location of the event is already mentioned in the script.

script.Parent.MouseButton1Click:Connect(function()
	script.Parent.Parent.Parent.Enabled = false
	game.ReplicatedStorage.Events.Event:FireServer()
end)
1 Like

I did some changes to the script and it worked, for some reason it’s almost the same thing as before, i just changed the kill part to :LoadCharacter() and the team line.

2 Likes