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

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

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

✓ Accepted answer

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!

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