Even if tool name matches script, it does not do what I want

Hi,

I have a script which is trying to detect what the tools name is so that not everything can touch it (E.G) A Players arm.

This does not appear to work however, if I touch the part with a tool that matches it, it prints and doesn’t match it.

Advice is appreciated.

if script.Parent.Parts.Body.EPad.Touched:Connect(function(hit)
if hit.Name == "Oyster Card" then
-- code if matches
else
print ("not an oyster card")
end
1 Like

is the “Oyster Card” the model or the part name

hit would be the part that caused the Touched event to happen, so you most likely need to do hit.Parent.Name and not hit.Name, since then name of hit would most likely be Handle or the names of other parts inside of the tool

Also why is there an if before the Touched event declaration?

It’s the name of the tool

Screenshot_12

I will try this.

If it is touched then do something else was my initial thinking

Hit.Parent.Name works


1 Like