Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

touch is not seeing any parts, what is the fix?

Asked by 2 years ago

hi, i was testing FindFirstChild instance but its not working at all, i tried to make it say human touched me when a humanoid touch it, but its not working

script.Parent.Touched:connect(function(onTouched)
local Human = onTouched:FindFirstChild("Humanoid")
if Human then
print("human touched me")
end
end)
0
I don't reallly what isn't working, but maybe it's the Part variable? Try naming the part "hit" instead of "onTouched". If that isn't it, maybe open the output, so we can see if any errors pop up ZIRFAL3 17 — 2y

2 answers

Log in to vote
1
Answered by 2 years ago

I don't quite know what you're trying to achieve but if you're trying to make it Print when a Humanoid touches it then try this script:

script.Parent.Touched:Connect(function(hit)
    if hit.Parent:FindFirstChild("Humanoid") then
        print("human touched me")
    end
end)

Any problems then feel free to tell me!

0
I will check it out when i can, when it worka i will accept the answer Natano2018 -5 — 2y
Ad
Log in to vote
1
Answered by
Ascarson4 138
2 years ago
Edited 2 years ago

You have to do onTouched.Parent:FindFirstChild("Humanoid") because onTouched will only give you the part that touched it, you want to get the parent of the part, which would presumably be a player, and then find the Humanoid within the player.

0
wait a minute. I recognize you..... hmmm where could it be from? :) NarwhalAndMe 141 — 2y

Answer this question