I'm new to scripting (lua) and im making a Defend the point game and i want to know what's wrong in this script so when the point (its an npc) dies all players of team Yellow should die
~~~~~~~~~~~~~~~~~
function die() if script.Parent.Humanoid.Health = 0 then game.Teams.Yellow.Players.Character.Humanoid.Health = 0 end
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() --"pairs" loops through this table for _,player in pairs(game.Teams.Yellow:GetPlayers()) do --safety check if player.Character then --easy way to kill player.Character:BreakJoints() end end end --connect npc death to your function script.Parent:WaitForChild('Humanoid').Died:connect(die)