Hi, I’m trying to make a pet system. You can buy or equip pets, when they’re equipped they should start looking at the player that bought the pet.
But the problem is that CFrame.lookAt
does not turn Pet or Pet Attachment.
I have tried just rotating normally with CFrame.Angles
or Orientation
that works fine on the attachment, but CFrame.lookAt
doesn’t work on the attachment.
Is there any other way, I could use to make the pets look at the player without using CFrame.lookAt
?
This is my script :
local ClonePet = rep.Pets:FindFirstChild(pet.Name):Clone()
ClonePet:SetPrimaryPartCFrame(HRP.CFrame)
ClonePet.Parent = player.Character
local ac = Instance.new("Attachment",HRP)
ac.Position = Vector3.new(math.sin(math.rad(spacing)) * 6, 0, math.cos(math.rad(spacing)) * 6)
ac.Visible = false
ac.Name = "ACharacter"
local ap = Instance.new("Attachment",ClonePet.PrimaryPart)
ap.CFrame = CFrame.lookAt(ap.Position, HRP.Position) --> This doesn't work for some reason
ap.Visible = false
ap.Name = "APet"
local alignPosition = Instance.new("AlignPosition")
alignPosition.MaxForce = 25000
alignPosition.Attachment0 = ap
alignPosition.Attachment1 = ac
alignPosition.Responsiveness = 25
alignPosition.Parent = ClonePet
local alignOrientation = Instance.new("AlignOrientation")
alignOrientation.MaxTorque = 2500
alignOrientation.Attachment0 = ap
alignOrientation.Attachment1 = ac
alignOrientation.Responsiveness = 25
alignOrientation.Parent = ClonePet