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

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

Asked by 4 years ago

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 ?

Closed as Not Constructive by hiimgoodpack and cmgtotalyawesome

This question has been closed because it is not constructive to others or the asker. Most commonly, questions that are requests with no attempt from the asker to solve their problem will fall into this category.

Why was this question closed?

2 answers

Log in to vote
1
Answered by
Elixcore 1337 Moderation Voter
4 years ago

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
Thank you, Works! kikocraftak233 18 — 4y
Ad
Log in to vote
0
Answered by
Psudar 882 Moderation Voter
4 years ago

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