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'.
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!