Hello! I've recently been trying to script an obby game. After completing the obby, players will step on a pad that will automatically team them safe and respawn them. I'm fairly new at scripting and I haven't been able to figure out how to do it. Any and all help is appreciated (in simple terms lol)! Thank you all so much!
As waifu said, that site has everything you need to know about teams. But for your easiness, here's an actual script.
part = workspace.partname part.Touched:connect(function(h) if game.Players:GetPlayerFromCharacter(h.Parent).Team == game.Teams.Teamname then else game.Players:GetPlayerFromCharacter(h.Parent).Team = game.Teams.Teamname game.Players:GetPlayerFromCharacter(h.Parent).Humanoid:TakeDamage(math.huge) end end)
https://wiki.roblox.com/index.php?title=Setting_Teams
This has everything you need to know about teams.
function OnTouch(Hit) local Torso = Hit.Parent:findFirstChild("Torso") if Torso ~= nil then script.Parent.BrickColor = Torso.BrickColor end end script.Parent.Touched:connect(OnTouch)
And change the brick color to what team you want them to switch to :D Also add a simple kill script like
script.Parent.Touched:connect(function(hit) if hit ~= nil then local char = hit.Parent if char ~= nil then local humanoid = char:FindFirstChild("Humanoid") if humanoid ~= nil then humanoid.Health = 0 end end end end)