Well, Touched isn't a boolean, it's a script signal. You'll get false because Touched exists as a valid signal but it doesn't return anything, so the statement reads it as nil.
If you want to know what Touched does, it's called as a script signal of the BasePart family (said family consists of Parts, NegativeParts, UnionOperations, etc.). When Touched fires, it passes the BasePart that made contact with the BasePart whose Touched event is listening. For example, if a player's character is R6 and their left leg hits the part listening for Touched, the passed BasePart will be Left Leg.
In order to associate any signal with any function (pre-written or post-written), Connect() is necessary. If no function was previously written for use with the signal, you can define this function within the signal:
BasePart.Touched:Connect(function(hit)
end)
Or, you can associate an existing function with it:
function foo()
end
BasePart.Touched:Connect(foo)
For the main issue at hand, every Instance has a property called Name, which is a string that represents the name given to the Instance. This property can be changed by the scripter at will; it's essentially a dynamic property. The rest is up to you.
3 comments
Hmm, all it does is immediately executes the code. Am I making a mistake?
Well, that means the signal is firing immediately. You should add if statements to check if the part is associated with anything relevant, like the part you want touching the listener.
Ok I have it working, how do I get it to do a specific part, like spawnlocation