I am trying to show a mesh inside a Viewport frame. I want to do it via scripting rather than the manual approach. Totally confused by the various types of meshes.
local camera = Instance.new(“Camera”, vf)
vf.CurrentCamera = camera
local cameraPosition = Vector3.new(3, 3, 3)
camera.CFrame = CFrame.new(cameraPosition, part.Position)
function makeBrickMove()
for i = 1,100 do
wait(.1)
part.CFrame = CFrame.Angles(0,(math.rad(i*10)),0)
end
end
The MeshId and TextureId require an asset link rather than a sole number.
The short version of such links looks like this: rbxassetid://<actual_id>, for example rbxassetid://123.
Regarding the texure ID, make sure you’re using the image ID rather than the decal ID.
Also read what XAXA said. To add on to it, there’s typically a description of the actual error in the console. IIRC, trying to edit a MeshPart’s MeshId actually prints something like “MeshIds cannot be changed at runtime”.
… If you need a walkthrough on how to do this with a Part/SpecialMesh, you can delete your mesh-making code (side note, you’re not actually rotating the mesh with your code, but the part you created above it) and replace it with this:
local specialMesh = Instance.new("SpecialMesh")
specialMesh.MeshId = "rbxassetid://152974867"
specialMesh.TextureId = "rbxassetid://152974868"
specialMesh.MeshType = Enum.MeshType.FileMesh
specialMesh.Parent = part
local part = Instance.new(“Part”, vf)
part.Position = Vector3.new(0, 0, 0)
part.Anchored = true
local specialMesh = Instance.new(“SpecialMesh”)
specialMesh.MeshId = “rbxassetid://152974867”
specialMesh.TextureId = “rbxassetid://2015542122”
specialMesh.MeshType = Enum.MeshType.FileMesh
specialMesh.Parent = part
local camera = Instance.new(“Camera”, vf)
vf.CurrentCamera = camera
local cameraPosition = Vector3.new(3, 3, 3)
camera.CFrame = CFrame.new(cameraPosition, part.Position)
function makeBrickMove()
for i = 1,100 do
wait(.1)
part.CFrame = CFrame.Angles(0,(math.rad(i*10)),0)
end
end