How to rotate these models?

I’ve tried:

-- Add rotation if pet is a cat or dog
if petClone.Name == "Cat" or petClone.Name == "Dog" then
    petClone.PrimaryPart.CFrame = petClone.PrimaryPart.CFrame * CFrame.Angles(0, math.rad(90), 0)
end

but for some reason it doesn’t work. The rest of the script does though. Inside the model is just a few meshparts and a hitbox (primarypart)

local tweenservice = game:GetService("TweenService")
local ws = game.Workspace
local camera = ws:WaitForChild("Camera")
local campart = ws:WaitForChild("CamPart")
rs = game:GetService("ReplicatedStorage")

rs.HatchEgg.OnClientEvent:Connect(function(pet)
	camera.CameraType = Enum.CameraType.Scriptable
	camera.CFrame = ws.CamPart.CFrame
	
	for i=1, 50, 1  do
		ws.forestegg.Icosphere.Size += Vector3.new(0.1, 0.1, 0.1)
		wait(0.01)
	end
	
	local explosion = Instance.new("Explosion")
	explosion.BlastRadius = 10
	explosion.BlastPressure = 0
	explosion.Position = ws.forestegg.Icosphere.Position
	explosion.ExplosionType = Enum.ExplosionType.NoCraters
	explosion.DestroyJointRadiusPercent = 0
	explosion.Parent = ws.forestegg.Icosphere
	
	ws.forestegg.Icosphere.Transparency = 1
	
	local petClone = pet:Clone()
	
	for i,v in pairs(petClone:GetChildren()) do
		if v:IsA("BasePart") then
			v.Anchored = true
		end
	end
	
	petClone:SetPrimaryPartCFrame(CFrame.new(ws.forestegg.Icosphere.Position,campart.Position))
	petClone.Parent = ws
	
	local TweenInfo = TweenInfo.new(
		2,
		Enum.EasingStyle.Bounce,
		Enum.EasingDirection.Out,
		0,
		false,
		0
	)
	
	local tween = tweenservice:Create(camera, TweenInfo, {CFrame = CFrame.new(petClone.PrimaryPart.Position + (petClone.PrimaryPart.CFrame.LookVector * 5) + Vector3.new(0, 0.75, 0), petClone.PrimaryPart.Position)})
	tween:Play()
	wait(5)
	camera.CameraType = Enum.CameraType.Custom
	ws.forestegg.Icosphere.Transparency = 0
	ws.forestegg.Icosphere.Size = Vector3.new(10.408, 13.108, 10.427)
end)
1 Like

Try:

 petClone:PivotTo(petClone:GetPivot() * CFrame.Angles(0, math.pi / 2, 0))
1 Like

Pivot is not a valid member of Part “Workspace.Dog.Hitbox” - Client - HatchAnimator:48

1 Like

It is PivotTo* not Pivot my bad sorry

1 Like

Like this?

local ws = game.Workspace
local camera = ws:WaitForChild("Camera")
local campart = ws:WaitForChild("CamPart")
rs = game:GetService("ReplicatedStorage")

rs.HatchEgg.OnClientEvent:Connect(function(pet)
	camera.CameraType = Enum.CameraType.Scriptable
	camera.CFrame = ws.CamPart.CFrame
	
	for i=1, 50, 1  do
		ws.forestegg.Icosphere.Size += Vector3.new(0.1, 0.1, 0.1)
		wait(0.01)
	end
	
	local explosion = Instance.new("Explosion")
	explosion.BlastRadius = 10
	explosion.BlastPressure = 0
	explosion.Position = ws.forestegg.Icosphere.Position
	explosion.ExplosionType = Enum.ExplosionType.NoCraters
	explosion.DestroyJointRadiusPercent = 0
	explosion.Parent = ws.forestegg.Icosphere
	
	ws.forestegg.Icosphere.Transparency = 1
	
	local petClone = pet:Clone()
	
	for i,v in pairs(petClone:GetChildren()) do
		if v:IsA("BasePart") then
			v.Anchored = true
		end
	end
	
	petClone:SetPrimaryPartCFrame(CFrame.new(ws.forestegg.Icosphere.Position,campart.Position))
	petClone.Parent = ws
	
	local TweenInfo = TweenInfo.new(
		2,
		Enum.EasingStyle.Bounce,
		Enum.EasingDirection.Out,
		0,
		false,
		0
	)
	
	local tween = tweenservice:Create(camera, TweenInfo, {CFrame = CFrame.new(petClone.PrimaryPart.Position + (petClone.PrimaryPart.CFrame.LookVector * 5) + Vector3.new(0, 0.75, 0), petClone.PrimaryPart.Position)})
	tween:Play()
	petClone.PrimaryPart:PivotTo(petClone:GetPivot() * CFrame.Angles(0, math.pi / 2, 0))
	wait(5)
	camera.CameraType = Enum.CameraType.Custom
	ws.forestegg.Icosphere.Transparency = 0
	ws.forestegg.Icosphere.Size = Vector3.new(10.408, 13.108, 10.427)
end) ``` Becuase  it still doesn't work unfortuantly.
1 Like

No do it on the petClone (Model) not the PrimaryPart

2 Likes

If your PrimaryPart is just a regular Part why not just rotate it so the required angle doesn’t have to be changed?

2 Likes

Thanks, you’re a legend! ////////////

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.