WooleyWool
(AWildWooleyWool)
October 19, 2020, 9:02pm
#1
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
degamer4k
(degamer4k)
October 19, 2020, 9:05pm
#2
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
WooleyWool
(AWildWooleyWool)
October 19, 2020, 9:05pm
#3
I’ve tried that, it still gives me that error.
degamer4k
(degamer4k)
October 19, 2020, 9:06pm
#4
Can i see the code for when you have tried that please
WooleyWool
(AWildWooleyWool)
October 19, 2020, 9:07pm
#5
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’
degamer4k
(degamer4k)
October 19, 2020, 9:10pm
#6
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
degamer4k
(degamer4k)
October 19, 2020, 9:17pm
#9
I think this is because the primary part hasn’t been defined
WooleyWool
(AWildWooleyWool)
October 19, 2020, 9:17pm
#10
@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