Cant change team with remote event

Im trying to make it so if a player is arrested it fires a remote that put the target player on the jailed team but it will not change the players team

ive tried to look on youtube and the developer hub for solutions

this is my code for the server script

	game.ReplicatedStorage.Arrest.Reason:FireAllClients(target, fine,tj)
	workspace:FindFirstChild(target):MoveTo(script.Jail.Value.Position)
	workspace:FindFirstChild(target).Humanoid.WalkSpeed = 16
	game.Players.target.Team = game.Teams.Jailed
end)

game.ReplicatedStorage.Arrest.Timer.OnServerEvent:Connect(function(player, tj)
	local timer = player.leaderstats.Timer
	timer.Value = tj
end)

game.ReplicatedStorage.Arrest.Count.OnServerEvent:Connect(function(player)
	local timer = player.leaderstats.Timer
	timer.Value = timer.Value - 1
	wait(1)
end)

game.ReplicatedStorage.Arrest.Release.OnServerEvent:Connect(function(player)
	workspace:FindFirstChild(player.Name):MoveTo(script.Unjail.Value.Position)
	player.Team = game.Teams.Citizen
end)

game.ReplicatedStorage.Arrest.ToJail2.OnServerEvent:Connect(function(player)
	workspace:FindFirstChild(player.Name):MoveTo(script.Jail2.Value.Position)
end)```

if anyone can help that would be great
1 Like

To change a players team you have to use player.TeamColor not player.Team

https://developer.roblox.com/en-us/api-reference/property/Player/TeamColor

(No wait nvm this reply might not be right Imma have another look.)
(Yeah I just looked into it lol)

player.Team work the same with player.TeamColor

did you got any error in the output?

This line might not work as “target” is not an actual object in players it should be

game.Players[target.Name].Team

or even just

target.Team

actually

For the first remote event you fire I would suggest using WaitForChild() since when you say game.Players.target.Name you assume that the player is in the game and a player, and also you are using .Team which I am not sure if its even a property or deprecated but you should use TeamColor like in the example below and replace the template text from the BrickColor.new() with the color of the team, in letters for example Really red, you can find more about it here.

game.ReplicatedStorage.Arrest.Reason:FireAllClients(target, fine,tj)
	workspace:FindFirstChild(target):MoveTo(script.Jail.Value.Position)
	workspace:FindFirstChild(target).Humanoid.WalkSpeed = 16

	game.Players:WaitForChild(tostring(target.Name)).TeamColor = BrickColor.new("The team's color")
end)

This can create a possible yield, AND you have a display name, so the name is likely not equal to players name. A better way to go about that is just player.Character, Since you have player just do:
[edit, next time remember to put prints around the place, find what is working, and what is not.]

player.Character:MoveTo(script.Unjail.Value.Position)--position

no i did not get any warning or errors