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

How do you make someone switch teams when they touch a player?

Asked by 2 years ago
Edited 2 years ago

I want to make a tag game so when you touch someone the tagger goes on the runner's team and the runner goes on the tagger's team. I also want to know how to make all the runners turn into taggers (and vice versa) at a specific time in the match.

1 answer

Log in to vote
0
Answered by 2 years ago
Edited 2 years ago

Hello PeterParker17386,

This is a simple task. and we recommend you give it a shot before asking! but anyways:

You probably want to use a .Touched Event with "Touching a player" And a function with a loop inside for the all runners into taggers. I have made some scripts for you!

These scripts have not been tested!!

This script should turn the tagger that touches a runner to the runners team and vice versa

-- this has to be in a local script. probably inside of replicatedstorage or similar. but exploiters may be able to just delete it. but i dont have the time to make a fully functional tag script with remotes and more for you!
local player1 = game.Players.LocalPlayer
    player1.Character.HumanoidRootPart.Touched:Connect(function(hit)
        local player2 = hit.Parent
        if player2.Team == game.Teams.Taggers then
            player1.Team = game.Teams.Taggers
            player2.Team = game.Teams.Runners
        end
    end) 

This one should turn all runners into taggers and vice versa

function teamAllPlayers(team)
for i, v in pairs(game.Players:GetChildren()) do
    v.Team = game.Teams[team]
end

teamAllPlayers(Taggers) -- change this to Runners if you want them all to be runners

Hopefully this helps and they work!

Ad

Answer this question