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

[SOLVED] Why is Humanoid.Died not working on anchored characters?

Asked by 2 years ago
Edited 2 years ago

When I kill an anchored character with a sword, Humanoid.Died works. However, when I shoot it with a Hyperlaser Gun, it doesn't work.

I tried editing the tool script, I tried unanchoring, I tried SetNetworkOwner(nil), I tried changing the HumanoidState, I tried using Humanoid:TakeDamage(), and I tried using Humanoid.ChildAdded since the tool script tags the Humanoid, nothing works. I tried possible answers and solutions, still nothing works.

If you know a way, please leave your solutions and I will try them all. Thank you! ^^

Respawn Script: (the script that the Humanoid.Died event is used)

1local zombie = script.Parent
2local hum = zombie:FindFirstChildOfClass("Humanoid")
3 
4hum.Died:Connect(function()
5    local mrclone = game.ServerStorage:FindFirstChild(zombie.Name):Clone()
6    mrclone.Parent = workspace.Monsters
7    mrclone:SetPrimaryPartCFrame(workspace.JennaSpawn.CFrame)
8    zombie:Destroy()
9end)

Tool Script:

001--Rescripted by Luckymaxer
002 
003Tool = script.Parent
004Handle = Tool:WaitForChild("Handle")
005 
006Players = game:GetService("Players")
007Debris = game:GetService("Debris")
008 
009Speed = 100
010Duration = 1
011 
012NozzleOffset = Vector3.new(0, 0.4, -1.1)
013 
014Sounds = {
015    Fire = Handle:WaitForChild("Fire"),
View all 260 lines...

2 answers

Log in to vote
0
Answered by 2 years ago

I finally found the solution! I actually don't have to change the Respawn Script, instead, it was the Tool Script. In lines 129-130, it removes any LocalScript and Script inside the character, including the Respawn Script.

1elseif v:IsA("LocalScript") or v:IsA("Script") then
2    v:Destroy()
3end

What I did was I made an "if" statement to tell if the script name is "Respawn" or not.

1elseif v:IsA("LocalScript") or v:IsA("Script") then
2    if v.Name ~= "Respawn" then
3        v:Destroy()
4    end
5end

I tried it and it now works! Thank you to the other person who answered this, but your script didn't work.

Ad
Log in to vote
-1
Answered by 2 years ago
Edited 2 years ago

Hello,

Instead of Humanoid.Died use Humanoid.HealthChanged, you can check if the new Humanoid Health Value is less or equal to 0. That will be like,

Tip: Humanoid.HealthChanged has first Parameter of Newhealth

1local Zombie = script.Parent
2local Humanoid = zombie:FindFirstChild("Humanoid")
3 
4Humanoid.HealthChanged:Connect(function(NewHealth)
5    if NewHealth <= 0 then
6        -- Do stuff
7    end
8end)
0
That could be it but my guess is that the server isn't picking up the health locally. That's why he needs to make a remote event to pass things to a server script VAnkata20 135 — 2y
0
you dont need remote events to get health Hi_People1133 218 — 2y
0
Rlly. Why VAnkata20 135 — 2y
0
@VAnkata20 The tool and the respawn script are both server-sided T3_MasterGamer 2189 — 2y
View all comments (2 more)
0
Thank you @Hi_People1133 I'll try it later. T3_MasterGamer 2189 — 2y
0
Didn't worked sadly. :'( T3_MasterGamer 2189 — 2y

Answer this question