While Icy_Qube's solution works in most cases, but in some circumstances it doesn't work.
Why it doesn't work
A general issue with checking if part.Parent.Name == "ReportingDosntWork" is that it doesn't know if it is a player or an NPC, or anything else that is named "ReportingDosntWork".
More efficient method
So, to make this work efficiently, you need to use the :GetPlayerFromCharacter function, which gets a player object from a character. The reason we use this is that all body parts are descendants of the character.
Finished Product
part = game.Workspace.Part
function onTouched(hit)
if game.Players:GetPlayerFromCharacter(hit.Parent) then
hit.Parent.Humanoid.Health = 0
end
end
part.Touched:Connect(onTouched)
1 comment
You need to make a script to check if player touch it