Unable to assign property MeshId. Script write access is restricted?

So today i figured out i cant assign mesh id’s with scripts, im making an fps game and my arms arent separate from the gun models which means i want my script to cycle through each gun model in replicatedstorage and change the meshid but apparently I cant somehow i can set textures and decals but not mesh’s. Is there any way to combat this? and if not this must be a huge joke.

6 Likes

You could use InsertService:LoadAsset() and set all the properties.

local Service = game:GetService("InsertService")
local Success, Model = pcall(Service.LoadAsset, Service, ID)
if Success then
    local MeshPart = Model:FindFirstChildOfClass("MeshPart")
    MeshPart.Parent = workspace
else
    warn(Model)
end
7 Likes

Im trying to change a meshparts ID not to get a meshpart from the website

1 Like

You just can’t, one option is to use SpecialMesh and set it with the id.

2 Likes

MeshPart.MeshId property has NotAccessible tag on it, which means you can’t access the property via a Lua code:


You need to either create a new MeshPart with MeshId using @SOTR654’s solution or the other solution provided by him/her.

well, this is a tough decision, ill have to bump out of this project, too much work considering i have too much weapons.

2 Likes

That is crazy considering u can do so much yet cant change meshparts, also i cant do @SOTR654 's way, too much work, i have alot of weapons and changing all those to special meshes is extra work i’ll not put my hands on. I’m still baffled by this.

4 Likes

I ran into this issue while trying to write a replay system today. Not being able to assign a mesh ID is going to make this far more complicated to be able to serialize/deserialize the parts for replay. This is going to to require me to clone all of the meshes into a storage folder, spawn in parts in the folder based on id versus just assigning it alone. I would post this reply in the suggestions section but I don’t have access there…

1 Like

I just ran into this too. But then I remembered something I read somewhere about WHY we’re not allowed to do it. Apparently the engine calculates the collision data for all parts at the start, so if the mesh data for a mesh part changes, it would require the engine to recalculate the collision data. Since the engine will not do that, the collision data will be wrong. With that in mind, creating a new MeshPart by script will break things. So Roblox decided to not allow us to do this.

Personally, I think this is asinine because that excludes a usable class from scripting.

10 Likes

Oof fine roblox i’ll just premake the parts stick them in storage and clone them…

Edit actually…
InsertService:CreateMeshPartAsync(meshid,0,0)
exists

this function is only accessible through the command bar and plugins, this will not work

1 Like

can’t you just pre-load assets and set their transparency to 0 until you need them?

you are wrong… InsertService:CreateMeshPartAsync(meshid,0,0) is a valid way to insert meshes. that’s how I do it and works fine

use special mesh instead of the normal one , you can change the special mesh mesh id using scripts.

i kind of worded my response bad, what I meant is that the property meshid is read only so you can’t edit it with scripts. this is a method that is a great alternative to get around it

1 Like

I discovered a way around this problem. Take a look at InsertService:CreateMeshPartAsync. The document even says that this is the only way to do this.