ViewportFrame issues

Hi, I am trying to make a character how up in the viewport frame, however, I keep on seeing this issue: Position is not a valid member of Model “Players.MysticalLuma.PlayerGui.ScreenGui.CharacterSelectScreen.CharacterViewer.Pirate”

local viewportframe = script.Parent.CharacterViewer

local viewportcamera = Instance.new("Camera")
viewportframe.CurrentCamera = viewportcamera
viewportcamera.Parent = viewportframe

local character = viewportframe.Pirate

viewportcamera.CFrame = CFrame.new(Vector3.new(0,2,12), character.Position)
1 Like

A model does not have a position. You can use the primary part position of the model or the humanoid root part which is in R6 and R15 models

2 Likes

I’ve tried that, it still gives me that error.

Can i see the code for when you have tried that please

local viewportframe = script.Parent.CharacterViewer

local viewportcamera = Instance.new("Camera")
viewportframe.CurrentCamera = viewportcamera
viewportcamera.Parent = viewportframe

local character = viewportframe.Pirate

viewportcamera.CFrame = CFrame.new(Vector3.new(0,2,12), character.PrimaryPart.Position)

Here’s the error: Players.MysticalLuma.PlayerGui.ScreenGui.CharacterSelectScreen.LocalScript:9: attempt to index nil with ‘Position’

The code is correct I think, have you set the primary part for the model as this isn’t done automatically

1 Like

By the way, that error means that the word before Position is nil (if you read it carefully it says you’re trying to index something that is nil with Position, meaning the thing’s position you are trying to get is nil).

1 Like

You can try also

Blockquote character:FindFirstChild(“HumanoidRootPart”). Position

1 Like

I think this is because the primary part hasn’t been defined

@ScriptingSausage @degamer4k It’s starting to work, i added the model to the Workspace, cloned it, and added it to the frame. Here is my working code:

local viewportframe = script.Parent.CharacterViewer

local viewportcamera = Instance.new("Camera")
viewportframe.CurrentCamera = viewportcamera
viewportcamera.Parent = viewportframe

local character = game.Workspace.Pirate:Clone()
character.Parent = viewportframe

viewportcamera.CFrame = CFrame.new(Vector3.new(0,2,12), character.PrimaryPart.Position)

I don’t now what is the difference between positions, but it works and I am happy.

2 Likes