Is it possible to set a mesh's properties via a script?

I want to make a script that changes my tool’s meshID and texture. Here’s the script I made, but it doesn’t seem to be working.

local mesh = script.Parent.Handle.Mesh.meshId
local texture = script.Parent.Handle.Mesh.textureId

mesh = 151738660
texture = 2222623249

I figured the full url wouldn’t be necessary or work either.

mesh = 151738660
texture = 2222623249

The mesh or texture must be are string

mesh = "151738660"
texture = "2222623249"

The mesh still doesn’t change. I’m not getting any errors though

you cannot set the property if the property is a variable. you also spelled the properties wrong. here is the code that should work:

local mesh = script.Parent.Handle.Mesh


mesh.MeshId = 151738660
mesh.TextureId = 2222623249
1 Like

Convert those numbers to a rbxassetid string.

1 Like

Do any of you know how a content ID works?

You can’t set a MeshPart’s MeshID using a script, you must use a SpecialMesh for that. Now, set the texture and mesh ids using:

local SpecialMesh = script.Parent.Handle.Mesh

SpecialMesh.MeshId = "rbxassetid://151738660"
SpecialMesh.TextureId = "rbxassetid://2222623249"
1 Like

No. It should be:

local Tool = script.Parent
local Handle = Tool.Handle
local SpecialMesh = Handle.Mesh
local idPrefix = 'rbxassetid://'

SpecialMesh.MeshId = idPrefix .. 151738660
SpecialMesh.TextureId = idPrefix .. 2222623249

--optional
Tool.TextureId = SpecialMesh.TextureId
2 Likes

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.