So, I am curious
local part1 = Insance.New("Part") part1.Name = "Part" local part2 = Insance.New("Part") part2.Name = "Part" local part3 = Insance.New("Part") part3.Name = "Part" part2:Destroy()
will lua get confused by this? will it destroy a random part? i tried printing the vars but it just says "part" so my question is, is part1 variable tied to the part it created or is it just pointing at the name? also, when i destroy part2 will the variable simply be set to nil?
Lua will not get confused by this. The variables, in this case, are pointing to the object; It will not matter if they are all given the same name.
When you print the object, it does print the name. However, you should be able to click on the name in the output, and it would open up the hierarchy for that object in the explorer.
It would be different if you were using the variable to search for an object. Let us say you had multiple parts in the workspace with the same name (e.g. "Part"); if you were to try and get an object named 'Part' from the workspace, it would only return the first one it finds.