local function addFighter(f)
table.insert(fighters, f)
table.insert(active, f)
fighter = f
local humanoid = fighter:FindFirstChild('Humanoid')
update()
humanoid.Died:Connected(function()
table.remove(active, table.find(active, f))
print('someone died in team '..i..',',#active,'left')
if #active < 1 then
gui.MatchLost:Fire(frame.Name)
end
update()
end
end)
Not sure if this will work but you can try it I guess.
From what i have understood so far, you are trying to change the health of the Humanoid from a Client sided way, which is not possible since it won’t actually change the Server Sided(whatever is in Workspace) value of the humanoid.Health,
I did put a block inside the workspace, with a Humanoid element inside of it, then i did create a script in the workspace and wrote this code inside,
local humanoid = game.Workspace:WaitForChild("HardNinjaGreatorDev2"):FindFirstChild("Humanoid")
local min_health = 0
local died = false
while died == false do
if humanoid.Health <= min_health then
print("i died")
died = true
end
wait(1)
end
then i did create a script inside workspace to change the humanoid health into 0 after 5 seconds
The problem you are facing is because you are changing the NPC’s health from a Client Sided way (ex. Local Script, a script inside ScreenGui or player related instead).
I would recommend you to take a look on Remote Events and try to get a better understanding between Server Side and Client Side before you continue, since it will help you a lot with the kind of game you are making
Actually I’m not trying to change the health, I am just trying to detect what the health is and when the humanoid dies from the client. I have tried making a remote event which also does not work. I made a new topic regarding that here.
The problem on the code is not that it doesn’t find if the humanoid has died or not, the problem is that he is trying to change the health value of the fighter(npc) through a local script on the server side, which is not possible to do
Yes, and i am saying the problem is from where he’s changing the health from, if the script is a local script and the actual NPC character is inside workspace, the actual humanoid health won’t change on the NPC, it will only change locally on the player, meaning it will never run the check since the actual health of the NPC won’t change to nil