Hi!
I believe you mixed up "SetPrimaryPartCFrame" with "PrimaryPart". SetPrimaryPartCFrame is a void function, while PrimaryPart is the property.
There is a different, more recommended method made by TigerCaptain (I credit him for this script!) This is a function that find all the baseparts in the model that follows the offset in unity with the PrimaryPart. This script will use ToObjectSpace() that converts world coordinates to object coordinates, to find the offset between any part and the PrimaryPart. The model MUST have a PrimaryPart otherwise this will not work.
I suggest you examine the script to learn along the way.
local Main = script.Parent
local function tweenModel(model)
if not model.PrimaryPart then return end
local details = {}
local function getParts(par, t)
local t = t or {}
for i,v in pairs(par:GetChildren()) do
if v:IsA("BasePart") then
t[#t+1]=v
else
t = getParts(v, t)
end end
return t
end
for i,part in pairs(getParts(model)) do
if part ~= model.PrimaryPart then
details[part] = model.PrimaryPart.CFrame:toObjectSpace(part.CFrame)
end end
local con = model.PrimaryPart.Changed:connect(function()
for part,offset in pairs(details) do
part.CFrame = model.PrimaryPart.CFrame*offset
end end)
while wait() do
Main.PrimaryPart.CFrame = Main.PrimaryPart.CFrame * CFrame.fromEulerAnglesXYZ(-.25,0,0)
end
end
tweenModel(Main)
Click "Accept Answer" if this was the answer you were looking for! Comment if you have any more concerns!
2 comments
This worked for me, thanks for the help!
No problem!