✓ Accepted answer
Your script errors
In my solution, I got rid of these errors for you. I'll be using a regular script inserted into a part in workspace.
How to/Solution
I would suggest checking if the part's name is "Torso",
function ontouch(hit)
if hit.Name == "Torso"then
print ("ow")
end
end
Script.Parent.Touched:connect(ontouch)
I added some fixes to your script as well.
But what if you have parts in your game named "Torso"?
I would suggest making sure that what touched the part was a Humanoid,
function ontouch(hit)
if not hit.Parent:FindFirstChild("Humanoid") then return end
if hit.Name == "Torso"then
print ("ow")
end
end
Script.Parent.Touched:connect(ontouch)
Returns end if the part's parent doesn't have a humanoid
But what if it's not a player?
Check if it's a player,
function ontouch(hit)
if not game.Players:GetPlayerFromCharacter(hit.Parent) then return end
if hit.Name == "Torso"then
print ("ow")
end
end
Script.Parent.Touched:connect(ontouch)
Returns end if the part's parent is not a character of a player
You could of course do this with arms and legs as well.
Hope I helped!
Good Luck!
If I helped you, make sure to hit that accept button!
1 comment
I added a few more detail for your benefit.