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

Tool that changes the team of a player?

Asked by
lushguy 13
6 years ago

I am making a tag like game with the tagger having a tool but i want it when the tag tool comes in contact with a player that is on the other team. that player changes teams how do i do that?

1 answer

Log in to vote
0
Answered by 6 years ago

Just setup the TeamName variable to match the Team you want to change the tagged person to.

--Assuming the script is directly inside the tool:

local Handle = script.Parent:WaitForChild("Handle")
local TeamName = "" -- Put name of the team between the quotes
local NewTeam = game.Teams:FindFirstChild(TeamName)

Handle.Touched:Connect(function(partHit)
    if partHit.Parent:FindFirstChild("Humanoid") and partHit.Parent ~= script.Parent.Parent then
        local Tagged = partHit.Parent
        game.Players:GetPlayerFromCharacter(Tagged).TeamColor = NewTeam.TeamColor
    end
end)
0
Thank you very much this worked perfectly :) lushguy 13 — 6y
Ad

Answer this question