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

Manual Team Changing if in Group?

Asked by
craigun -1
3 years ago

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.

0
Try using the team's team color, and not brickcolor PoWerofThEePg 43 — 3y

1 answer

Log in to vote
0
Answered by
Sparks 534 Moderation Voter
3 years ago

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)
Ad

Answer this question