Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

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

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.

5 comments

0

Filtering Enabled or not?

0

Post the error please and tell me whether it is FE or not

0

No, FilteringEnabled is not enabled.

0

:connect is deprecated, use :Connect

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)

1 answer

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 

1 comment

0

ok, thanks!

This discussion is preserved as it was. New answers, comments, and votes are closed.