I am trying to make a teamchanger gui issue is everytime I try changing teams it creates a new team (Neutral) and puts me in it. I already have one team that is autoassignable which is citizens then I got 2 teams one is prisoner and the other cop which has autoassignable off.
Local script in button
script.Parent.MouseButton1Click:Connect(function() local team = script.Parent.Text game.ReplicatedStorage.ChangedTeam:FireServer(team.Value) end)
Script in Severscriptservice
game.ReplicatedStorage.ChangedTeam.OnServerEvent:Connect(function(player, team) player.Team = team player:LoadCharacter() end)
The “Neutral” Team being created means that there is a player that hasn't been assigned to a team, which means that your script simply isn't updating the team of the player is in correctly.
This is likely due to what the other answer already mentioned:
It should be :FireServer(team)
and not :FireServer(team.Value)
as you have already declared team
as the .Text
property of an instance.
Edit: I recommend trying to change player.Team = team
to player.Team = game.Teams:FindFirstChild(team)
, since usually the Team
property of a Player takes a team-instance, not a string.
you don't need to put value at the end. game.ReplicatedStorage.ChangedTeam:FireServer(team)