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!

10 comments

0

Is the part created client side?

0

Nope, it's server side

0

Is it in a local script?

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.

0

try printing the name of both, and see what they output.

0

^ outside of the if statement

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.

0

you've just said what we said but less grammatically correct

0

This is really weird, no typos, no scripting mistakes, no case mistakes... Maybe it was lagging..?

0

Part.Parent.Name perhaps? You didn't really tell us where the script's located.