Humanoid.Died Isn't Working

So currently I have a respawn script, however it Humanoid.Died doesn’t fire. However if I put the script inside a dummy it works but when I put it inside a tree model with a humanoid it doesn’t work. No errors.

local RespawnTime = 2

while true do
	char = script.Parent
	clone = char:Clone()
	char.Humanoid.Died:wait()
	print("1")
	wait(RespawnTime)
	clone.Parent = game.Workspace
	script.Parent = clone
	char:Destroy()
end
1 Like

You are not using your logic to modify the script. The script code inside it wouldn’t change itself, if you parent it to something else, you must change some of the script lines to make sure it’s referring the character model.

I’m sorry but I don’t really understand what you are trying to say. I have a rough idea, but how would that have anything to do with Humanoid.Died not firing?

Read this code line.

char = script.Parent

First of all, you did not specify the char variable, you must create a new variable by using local. Second of all, script.Parent would get affected. If you parent this to a character model, it works fine because the variable contains the character model. However if you position it at somewhere else, for example SeverScriptService, the variable will contain ServerScriptService, which makes your script failed to work. Please use your logics.

Oh, thank you it works now, I understand

You should’ve understand this when learning basics of scripting.

Some times i just have one brain cell

Wait actually, the reason why it worked was because I named one of the Parts “HumanoidRootPart” and it worked.