You should use the .Died event of humanoids, which will trigger a function when the npc dies. You have to "connect" it to a function. Info on events / connections
Also, "game.Teams.Yellow.Players" does not make any sense, as "Players" is not a property of a team. However there is a function :GetPlayers() which will do this. It gives you a list of players, so you have to kill each player in the list using a loop. Unfortunately your simplicity does not work lol. Info on Generic for loops
function die()
for _,player in pairs(game.Teams.Yellow:GetPlayers()) do
if player.Character then
player.Character:BreakJoints()
end
end
end
script.Parent:WaitForChild('Humanoid').Died:connect(die)
3 comments
Well, you would use, as you have, a function that'll have a for loop, which will loop through the player's service, and if the NPC has "died," then it will execute the "death" function for players: I suggest a variable to accomplish all of this.
Thanks!
Np.