#nested model changes entire parent models pivot
1 messages · Page 1 of 1 (latest)
also how do i reduce network traffic size with remote events
i figured this one out
but not the original question
alright ill send it once i get home, or actually hold on
ok
actually uhh
its a pretty simple script and nesting
i have
workspace :
target
Model :
part
model :
part
script
script :
script.Parent:PivotTo(cframe.lookat(script.parent.PrimaryPart.Position, workspace.target.Position))
The reason I cant have videos or photos is because i only have discord on my phone.
anyhow, lets say we have both parts having a forward direction. I aim to have one part, the descendant one, pivot to another, but it seems that it affects the ancestor.
I see
** You are now Level 1! **
Try this
local childModel = script.Parent
local partToRotate = childModel.Part2
local targetPart = workspace.TargetPart
local function updateRotation()
local direction = (targetPart.Position - partToRotate.Position).Unit
partToRotate.CFrame = CFrame.lookAt(
partToRotate.Position,
targetPart.Position
)
end
--Triggering method
the same thing happened, was it because I had to weld it? it does work without welding, but i need it to be welded.
Also, where is direction used?
The direction can be deleted.
if you need it to be welded
You can try this:
local childModel = script.Parent
local partToRotate = childModel.Part2
local basePart = childModel.PrimaryPart -- or childModel.BasePart
local targetPart = workspace.TargetPart
-- Motor6D
local motor = partToRotate:FindFirstChildOfClass("Motor6D")
if not motor then
motor = Instance.new("Motor6D")
motor.Part0 = basePart
motor.Part1 = partToRotate
motor.C0 = CFrame.new() -- Part0 position:You can set it manually or motor.C0 = basePart.CFrame:ToObjectSpace(basePart.CFrame)
motor.C1 = CFrame.new()
-- Part0 position:You can set it manually or motor.C1 = basePart.CFrame:ToObjectSpace(targetPart.CFrame)
motor.Parent = partToRotate
end
local function rotatePartOnly()
local relativePos = partToRotate.Position - basePart.Position
local lookCFrame = CFrame.lookAt(
Vector3.new(0, 0, 0),
(targetPart.Position - partToRotate.Position).Unit * 10
)
motor.C1 = lookCFrame
end
ah it worked thx
** You are now Level 3! **