Changing the Name of a BasePart changes the part to no longer be a BasePart?

Hello All,

Does changing the name of an original part during gameplay stop the part from being recognized as BasePart? I’ve been messing around in game development using:

mouse = Player:GetMouse()

if mouse.Target then ....      -- (whatever to follow)

The Roblox Developer description for Target seems to say that mouse.Target only recognizes BaseParts. Alright then. I can create a part in Studio first, then launch the game, and the when I move the mouse over the part, mouse.Target works just fine. But, if during the game I execute a script to simply change the name of that part, then move the mouse over it, the part is no longer recognized by mouse.Target. It’s as if the name change, changed the part to no longer be a BasePart. This is a bit frustrating as my game won’t function as intended once the part isn’t recognized anymore. Any thoughts or clarification from anyone?

1 Like

I don’t really think that this topic should be in building support.

The name of an object has nothing to do with its class. You can safely rename parts and continue to check its ClassName or perform IsA without breaking your code.

if mouse.Target and mouse.Target:IsA("BasePart") then
    -- ...
end

FYI this should be in #help-and-feedback:scripting-support