Hi helpers, I'm trying to make a script so that, once a button is pressed, the player that clicked it will change to a different team. This is inside a LocalScript, which is inside StarterGui.
local SGui = game.StarterGui.ScreenGui local Duel = Instance.new("TextButton") local Player = game.Players.LocalPlayer Duel.Parent = SGui Duel.Position = UDim2.new(0, 0, 0.5, 0) Duel.Size = UDim2.new(0.1, 0, 0.1, 0) Duel.Text = "Duel Area" Duel.Font = "Bodoni" Duel.BackgroundColor3 = Color3.fromRGB(127, 142, 100) Duel.TextColor3 = Color3.fromRGB(0, 0, 0) Duel.TextSize = 27 Duel.BorderSizePixel = 0 function GoDuel(plr) plr.Team = game.Teams.Duelling end Duel.MouseButton1Down:connect(GoDuel)
The entire first chunk is only about the textbutton, so you can ignore that. There are two teams; Duelling, and Shooting Stalls. The player's team is supposed to switch from Shooting Stalls to Duelling.
If someone could find the error in this script, it would be much appreciated.
Roblox changed it so you must have it using ".TeamColor" at the end, Fixed code block:
function GoDuel(plr) plr.Team.TeamColor = game.Teams.Duelling.TeamColor plr.Character.Humanoid.Health = 0 --Remove this if you dont want them to change spawn locations. end