How to check if certain things is not a part

You can write your topic however you want, but you need to answer these questions:

  1. What do you want to achieve? Keep it simple and clear!
    I wan’t to check if the instance is not a “Part”

  2. What is the issue? Include screenshots / videos if possible!
    It seem like that the roblox api reference doesn’t have this and I don’t know what to do.

  3. What solutions have you tried so far? Did you look for solutions on the Developer Hub?
    I tried to find a ways to do it on devforum but I can’t seen to find anythings at all

Here a part of my code

local debug_ = {strict_rule={ClassName = true}}
function ChangeMesh(Parent,ID)
	local mesh = nil
	
	if Parent:IsA("Part") and Parent:FindFirstChildWhichIsA("SpecialMesh") then
		mesh = Parent:FindFirstChildWhichIsA("SpecialMesh")
	elseif Parent:IsA("Part") then
		mesh = Instance.new("SpecialMesh")
		mesh.Parent = Parent
    else
        print("Parent is not a part")
	end

	mesh.MeshId = "rbxassetid://".. ID

	return mesh
end

1 Like
if not(instance:IsA("BasePart")) then
--code
end
3 Likes