Issue with CFramePrimaryPart

I’m making a FPS game but i faced an issue while setting the CFrame primary part.
I’m getting an error that says:

13:08:10.185  Model:SetPrimaryPartCFrame() failed because no PrimaryPart has been set, or the PrimaryPart no longer exists. Please set Model.PrimaryPart before using this.  -  Client - LocalScript:19

this is my code:

local Script:

-- Services
local RunServices = game:GetService("RunService")
local Player = game:GetService("Players")
local RepStorage = game:GetService("ReplicatedStorage")
--Objects
local ViewModel = RepStorage:WaitForChild("MainGame"):WaitForChild("Guns"):WaitForChild("ViewModel"):Clone()
local Camera = workspace.CurrentCamera
--Modules
local Config = require(ViewModel:WaitForChild("Config"))
-- Main Code
ViewModel.Parent = Camera

local CF = CFrame.new()

function PositionModel()
	ViewModel:SetPrimaryPartCFrame(Camera.CFrame*Config.OffsetFromCamera)
end

RunServices.RenderStepped:Connect(PositionModel)

Module Script

local Config = {}

Config.OffsetFromCamera = CFrame.new(-1,1.2,1.5)

return Config

Thanks in advance!

you should do the camera offset like this, i really dont know what you are doing because i am banned off roblox

Player.Humanoid.CameraOffset = Vector3.new(0, 1, 0) -- you can adjust this

or if you want to set the cameras position to a part

local LocalPlayer = game.Players.LocalPlayer
local Part = workspace.Part

LocalPlayer.CurrentCamera.CFrame = Part.CFrame

Did you set a primary part for the model?

The first solution gives me the same issue, and the second one gives me
13:28:10.993 CurrentCamera is not a valid member of Player "Players.SuperMM_X" - Client - ClientScripts:15

Can you tell me how to set it? sorry for bothering you

Sorry for the late reply, you can set the primary part by selecting your model then going to its primary part property and then click the part inside the model that you want to be its primary part

2 Likes