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
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.
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.]