Now I wish to be able to change teams by clicking on a button on a screen (Just like Jailbreak).
The script is a LocalScript
And I've come up with this so far:
local Button = script.Parent local Team = game.Teams local Player = game.Players.LocalPlayer function OnClicked(Teams) Player.Team = "Astronauts" end Button.MouseButton1Down:connect(OnClicked)
Edit: I have edited the script below to reset the player after changing teams
You would use Remote Events, not because changing teams isn't simple, it is; but with FIlteringEnabled, if you change your team on a Local Script you will see yourself on the Astronauts team but other players won't, and that will cause confusion within your game. A server script will work, but this can't be handled with just a server script, as they won't work inside a player, and they can't access the PlayerGui.
So, you would use both.
Put a RemoteEvent inside ReplicatedStorage named ChangeTeam
Make sure there is a Team inside the Teams folder named Astronauts
In your LocalScript
local Button = script.Parent local Teams = game:GetService("Teams") local event = game:GetService("ReplicatedStorage"):WaitForChild("ChangeTeam") local Player = game.Players.LocalPlayer function OnClicked() event:FireServer(Teams:WaitForChild("Astronauts")) end Button.MouseButton1Down:Connect(OnClicked)
In a Script in the ServerScriptService
local event = game:GetService("ReplicatedStorage"):WaitForChild("ChangeTeam") event.OnServerEvent:Connect(function(player,team) player.Team = team if player and player.Character then player.Character:BreakJoints() end end)