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

How to Change Team and Respawn on Touch?

Asked by
ghaybe 5
5 years ago

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!

3 answers

Log in to vote
-1
Answered by 5 years ago
Edited 5 years ago

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)
0
Didn't test it, but hopefully it works. joshthegamer456 93 — 5y
0
should work seith14 206 — 5y
0
Sorry for another question, but is there a way to get the person to be respawned as well? Thank you so much for your help in this! :) ghaybe 5 — 5y
0
Oh! I completely forgot! joshthegamer456 93 — 5y
View all comments (6 more)
0
There! Should work now. joshthegamer456 93 — 5y
0
For some reason the script was working last night, but today it's not working. The player isn't respawning or the team isn't changing. What could be wrong? I've checked it over multiple times to make sure I didn't make an error in copying or retyping. ghaybe 5 — 5y
0
Any output? joshthegamer456 93 — 5y
0
09:58:36.700 - Infinite yield possible on 'Workspace.Penguin:WaitForChild("Torso")' 09:58:36.700 - Stack Begin 09:58:36.701 - Script 'Workspace.Penguin.Animate', Line 4 09:58:36.701 - Stack End 09:58:36.702 - Infinite yield possible on 'Workspace.Penguin:WaitForChild("Torso")' 09:58:36.702 - Stack Begin 09:58:36.703 - Script 'Workspace.Penguin.Movement', Line 5 09:58:36.703 - Stack End 09:58:37.98 ghaybe 5 — 5y
0
EDIT: The teaming is working now - I made an error on my part. However, the respawn is still not working. ghaybe 5 — 5y
0
Hm. I could just kill the player, but that would be bad practice. Meh, I guess just killing them WOULD work. joshthegamer456 93 — 5y
Ad
Log in to vote
0
Answered by
waifuSZN 123
5 years ago

https://wiki.roblox.com/index.php?title=Setting_Teams

This has everything you need to know about teams.

Log in to vote
0
Answered by 3 years ago

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)

Answer this question