Mesh id load not in meshpart by add it by clicking button

i will make a game where player can build but i have this script in the button to insert objects but the mesch id load not in the mesch part

script.Parent.MouseButton1Click:Connect(function()
	local new = Instance.new('MeshPart')
	new.Parent = game.Workspace
	new.MeshId = 'rbxassetid://13543119482'
end)

i get this error Unable to assign property MeshId. Script write access is restricted

how to get the acces to made a mech part with the mech i created

the mech is publiched to marketplace is it needed

as it article already made is will i a link to it please

1 Like

You cannot set the MeshId of a MeshPart. Instead make use of a Mesh Instance and set it to custom.

Like this or how do that instance.

    script.Parent.MouseButton1Click:Connect(function()
	local new = Instance.new('MeshPart')
	new.Parent = game.Workspace
	new.MeshId = 'rbxassetid://13543119482'
        New. Instance = custom -- property name for custom 
end)
1 Like

That error indicates that the script is attempting to assign a value to a property that it does not have permission to modify, thus the MeshId property of the MeshPart is read only meaning it cannot be changed by scripts. You need to use the InsertService instead as it will allow you to insert models from the catalog into the game. Xx

Like this script

local InsertService = game:GetService("InsertService")

script.Parent.MouseButton1Click:Connect(function()
    local newMeshPart = Instance.new('MeshPart')
    newMeshPart.Name = "NewMeshPart"
    newMeshPart.Anchored = true
    newMeshPart.Parent = game.Workspace

    local meshId = "rbxassetid://123456789" -- Replace with the desired MeshId

    -- Function to handle mesh insertion
    local function handleMesh(mesh)
        if mesh then
            newMeshPart.MeshId = meshId
            newMeshPart.TextureID = "" -- Optional: Set the texture ID if needed
            
            -- Set the properties of the mesh part as desired
            newMeshPart.Position = Vector3.new(0, 0, 0)
            newMeshPart.Size = Vector3.new(1, 1, 1)
            newMeshPart.Color = Color3.new(1, 1, 1)
            
            print("MeshPart created successfully!")
        else
            print("Failed to load mesh with MeshId:", meshId)
        end
    end

    -- Load the mesh asynchronously using the InsertService
    local success, mesh = pcall(function()
        return InsertService:LoadAssetMeshAsync(meshId)
    end)

    if success and mesh then
        handleMesh(mesh)
    else
        print("Failed to load mesh with MeshId:", meshId)
    end
end)

And can I set the mesches off sale in marketplace or work it then not

Yes that looks good, as for your question about setting meshes off sale in the marketplace, if you’re using an asset from the catalog, you don’t have control over its availability. The availability of assets on the marketplace is determined by the asset owner. You can use any publicly available asset ID in your game without needing to worry about its availability. However keep in mind that if the asset owner decides to remove or modify the asset, it may affect your game if it relies on that asset. Xx

Ok but I use my own mesches but as it for insert it must be published then it’s during mounts to get all in the game because I have a limit from 10 a month