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

.Touched wont work if I'm trying to find the name of a part?

Asked by 5 years ago

im trying to make a certain thing happen if a part touches a part with the same name. For some reason it just wont work, here is the code that I am using: (its a script inside of the part)

script.Parent.Touched:Connect(function(Part) --clash
    print("touched")
     if Part.Name == script.Parent.Name then
        print("e")
    end
end)

It prints "touched", but it doesn't print "e". The Part's name is the same as the script's parent so I don't understand why it won't work.

Thanks for reading!

0
Is the part created client side? User#24403 69 — 5y
0
Nope, it's server side techlevel89 9 — 5y
0
Is it in a local script? LoganboyInCO 150 — 5y
0
Maybe the capitalisation is not the same. Lua is case sensitive. There's no other reason why it doesn't print, other than what I just said or the touching part is created client side, or in general the name isn't the same. User#24403 69 — 5y
View all comments (6 more)
0
try printing the name of both, and see what they output. DinozCreates 1070 — 5y
0
^ outside of the if statement User#24403 69 — 5y
0
If it's not printing anything the condition is not respected. That's clear. No need to search further. Trying using else for see what's wrong it must be easy to fix with that. Print the two names. ScriptAbyss 10 — 5y
0
you've just said what we said but less grammatically correct DinozCreates 1070 — 5y
0
This is really weird, no typos, no scripting mistakes, no case mistakes... Maybe it was lagging..? SCP774 191 — 5y
0
`Part.Parent.Name` perhaps? You didn't really tell us where the script's located. TheeDeathCaster 2368 — 5y

Answer this question