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

Manual Team Changing if in Group?

My manual team changing isn't working really, when I do it, it just auto kills me if I am in the group I am trying to switch to the team for.

function Click(mouse) -- leave this if script.Parent.Parent.Parent.Parent.Parent:IsInGroup(6617207) then script.Parent.Parent.Parent.Parent.Parent.TeamColor = BrickColor.new("Bright red") script.Parent.Parent.Parent.Parent.Parent.Character.Humanoid.Health = 0 end end

script.Parent.MouseButton1Down:connect(Click)

It should switch team but auto kills me instead without changing team.

1 comment

0

Try using the team's team color, and not brickcolor

1 answer

✓ Accepted answer

You should be changing the Player's TeamColor to the TeamColor of the team you would like to switch to, not the BrickColor.

local team = game.Teams.YOURTEAMHERE
function Click(mouse) -- leave this 
	if script.Parent.Parent.Parent.Parent.Parent:IsInGroup(6617207) then
		script.Parent.Parent.Parent.Parent.Parent.TeamColor = team.TeamColor
		script.Parent.Parent.Parent.Parent.Parent.Character.Humanoid.Health = 0 
	end 
end

script.Parent.MouseButton1Down:connect(Click)

If this is a server script, you do not need to use TeamColors. Players have a .Team property which can be used on the server. You cannot change this property in a localscript because it will not replicate.

local team = game.Teams.YOURTEAMHERE
function Click(mouse) -- leave this 
	if script.Parent.Parent.Parent.Parent.Parent:IsInGroup(6617207) then
		script.Parent.Parent.Parent.Parent.Parent.Team = team
		script.Parent.Parent.Parent.Parent.Parent.Character.Humanoid.Health = 0 
	end 
end

script.Parent.MouseButton1Down:connect(Click)

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