PrimaryPart CFrame Trouble

I’m having trouble setting the Primary Parts CFrame, the error is in the line

script.Parent.PrimaryPart:SetPrimaryPartCFrame(Hinge.CFrame*CFrame.Angles(0, math.rad(5), 0))

Here’s my Current Script:

local ClickDetector = script.Parent.ClickDetector -->  *Click*
local sound = game.Workspace.Bunker.Base.Sound --> Alarm
local Hinge = script.Parent.PrimaryPart --> Explanatory?
local on = false --> Indicating if Alarm is Running
local S_On = script.Parent.Parent.Back.SwitchOn  --> Switch On
local S_Off = script.Parent.Parent.Back.SwitchOff --> Switch Off

 ClickDetector.MouseClick:Connect(function()
	if on == false then
	on = true
	S_On:Play()
	sound.Playing = true
	script.Parent.PrimaryPart:SetPrimaryPartCFrame(Hinge.CFrame*CFrame.Angles(0, math.rad(5), 0))
	wait()
	else
	on = false
	S_Off:Play()
	sound.Playing = false
	script.Parent.PrimaryPart:SetPrimaryPartCFrame(-Hinge.CFrame*CFrame.Angles(0, math.rad(5), 0))
	end
 end)

Hopefully you can help me, Thanks!

-Loaf/Syl

1 Like

You should be using this function with the model, not with the primary part.

Model:SetPrimaryPartCFrame(CFrame.new())

Also, I don’t recommend using this function anymore, since it’s deprecated. Instead use :GetPivot() (in replace of :GetPrimaryPartCFrame()) to get the Model’s CFrame and :PivotTo() (in replace of :SetPrimaryPartCFrame()) to set it, by the way these functions do not require a primary part.

Learn more: Pivot Editor: Full Release

Thank you, I placed Model.PrimaryPart:SetPrimaryPartCFrame(CFrame.new())

It was Just supposed to be Model.:SetPrimaryPartCFrame(CFrame.new())