Model not on position given with PivotTo

Hello, I would like to know why my visible model is not on the model in red, already the angle I had to orient it with 90° whereas it is supposed to be a clone and now it is above and not at the same position, how can I fix that?

image
Bomber :
image
Position I would like to have :
image

local function openDoor(door, endCFrame, endSize, duration)
	local tweenInfo = TweenInfo.new(duration, Enum.EasingStyle.Sine, Enum.EasingDirection.Out)
	local tweenGoal = {CFrame = endCFrame, Size = endSize}

	local tween = TweenService:Create(door, tweenInfo, tweenGoal)
	tween:Play()
	return tween
end

local function tweenModel(model, CF, duration)
	local info = TweenInfo.new(duration, Enum.EasingStyle.Sine, Enum.EasingDirection.Out)
	
	local CFrameValue = Instance.new("CFrameValue")
	CFrameValue.Value = model:GetPrimaryPartCFrame()

	CFrameValue:GetPropertyChangedSignal("Value"):Connect(function()
		model:SetPrimaryPartCFrame(CFrameValue.Value)
	end)

	local tween = TweenService:Create(CFrameValue, info, {Value = CF})
	tween:Play()

	tween.Completed:Connect(function()
		CFrameValue:Destroy()
	end)
end

rs.Events.Bomber.SpawnAndAnimation.OnServerEvent:Connect(function(player, modelHangar)
	if not modelHangar:FindFirstChild("Bomber") then
		local door1 = modelHangar:FindFirstChild("Door1")
		local door2 = modelHangar:FindFirstChild("Door2")

		if door1 and door2 then
			local endDoor1 = modelHangar:FindFirstChild("END-Door1")
			local endDoor2 = modelHangar:FindFirstChild("END-Door2")

			local tween1 = openDoor(door1, endDoor1.CFrame, endDoor1.Size, 1.5)
			local tween2 = openDoor(door2, endDoor2.CFrame, endDoor2.Size, 1.5)
			
			task.wait(2)
		end
		
		
		for _, object in ipairs(modelHangar.WallStorage.SupportBomber:GetChildren()) do 
			if object:IsA("Model") then
				for k, part in ipairs(object:GetChildren()) do 
					if part:IsA("Part") or part:IsA("MeshPart") then
						part.Transparency = 0
					end
				end
			elseif object:IsA("Part") or object:IsA("MeshPart") then
				object.Transparency = 0
			end
		end
		
		task.wait(0.1)
		
		local supportBomber = modelHangar.WallStorage.SupportBomber
		local endSupBom = modelHangar.WallStorage:FindFirstChild("END-SupportBomber")
		local tweenSupBomber = tweenModel(supportBomber, endSupBom.PrimaryPart.CFrame, 2)
		
		task.wait(2.1)
		
		if door1 and door2 then
			local startDoor1 = modelHangar:FindFirstChild("START-Door1")
			local startDoor2 = modelHangar:FindFirstChild("START-Door2")

			local tween1 = openDoor(door1, startDoor1.CFrame, startDoor1.Size, 1.5)
			local tween2 = openDoor(door2, startDoor2.CFrame, startDoor2.Size, 1.5)

			task.wait(1.6)
		end

		for _, object in ipairs(modelHangar.WallStorage.SupportBomber:GetChildren()) do 
			if object:IsA("Model") then
				for k, part in ipairs(object:GetChildren()) do 
					if part:IsA("Part") or part:IsA("MeshPart") then
						part.Transparency = 1
					end
				end
			elseif object:IsA("Part") or object:IsA("MeshPart") then
				object.Transparency = 1
			end
		end
		
		task.wait(0.1)
		
		local bomber = game:GetService("ReplicatedFirst").Bomber:Clone()
		bomber.Parent = modelHangar
		bomber.Name = "Bomber"
		bomber:PivotTo(
			modelHangar:FindFirstChild("SpawnPositionBomber").PrimaryPart.CFrame 
				* CFrame.Angles(math.rad(90),0,0)
		)
		bomber.Parent = workspace

		task.wait(0.25)

		bomber.Bomber.PP_Plane.PP_BomberScript.Enabled = true
	end
end)

The red one is “SpawnPositionBomber”, it’s a model, a clone from the real plane.

Instead of
modelHangar:FindFirstChild("SpawnPositionBomber").PrimaryPart.CFrame

You should do
modelHangar:FindFirstChild("SpawnPositionBomber"):GetPivot()
since you are using PivotTo

2 Likes

Probaby an issue with the model’s pivot.

Yeah that could be the issue actually, they should definitely test though.

1 Like

That might be the main reason yeah

Thank you guys, I didn’t know this, thanks again:!

1 Like