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

How can I make player "Die" or get killed after he changes his team ?

I have no idea on how to make a player that changes his teams, doesnt matter how, just when he gets to other team gets killed, or somehow reseted/refreshe, any help for that ?

2 answers

✓ Accepted answer

Hey, you could loop between the teams and connect whenever a player leaves (or joins, your choice) a team and kill them.

for i,v in next, game:GetService('Teams'):GetChildren() do 
	v.PlayerRemoved:Connect(function(plr)
		plr:LoadCharacter()
	end) 
end

1 comment

1

Thank you, Works!

I think the best way to do that is to use an event, grab their character and damage the humanoid/kill the player.

Something like this could be a good answer to your problem.

--team refers to the teams within your game
Team.PlayerRemoved:Connect(function(player)
	local character = player.Character
	if character then
		character:BreakJoints()
	end
end)
  • you could also do it like this if you find it better
Team.PlayerRemoved:Connect(function(player)
	local character = player.Character
	if character then
		character.Humanoid:TakeDamage(character.Humanoid.MaxHealth)
	end
end)

but both should work just fine

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