Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

I need to change a player's team! What is the error here?

Asked by 6 years ago

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.

0
Filtering Enabled or not? Nights_Alpha 0 — 6y
0
Post the error please and tell me whether it is FE or not Nights_Alpha 0 — 6y
0
No, FilteringEnabled is not enabled. cooldeath49 37 — 6y
0
:connect is deprecated, use :Connect T0XN 276 — 6y
0
T0XN :connect still works, so either way its going to be a different problem, cooldeath49, try basic troubleshooting first, try checking spelling, and if referenced items actually exist (and for god sake use enums) fanofpixels 718 — 6y

1 answer

Log in to vote
0
Answered by 6 years ago

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 
0
ok, thanks! cooldeath49 37 — 6y
Ad

Answer this question