Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

I have done everything right in a script, but its not working?

Here is the script:

script.Parent.Touched:Connect(function(hit)
	local humanoid = hit.Parent:FindFirstChild("Humanoid")
	if humanoid then
		humanoid.Health = 0
	end
end)

Once I play the game, no errors occur in the output, but it does not kill the player! I think it has something to do with 'FindFirstChild'.

4 comments

0

Is it in a LocalScript or a ServerScript?

0

ServerScript

0

Is the script inside the Part?

0

yes

1 answer

Sorry everyone, I answered the question myself. Previously, I had inserted a script into StarterCharacterScripts. The following code was inside:

script.Parent.Health:Destroy()

I wanted the player's health to not regenerate, so I decided to delete the health script. But, what I did not know was that the health script also managed when the player's health is deducted. So i deleted my script, and the problem was fixed!

This discussion is preserved as it was. New answers, comments, and votes are closed.