Your model is incorrectly aligned. Front of the model is not the “face” of the pet. Otherwise CFrame.new(pos, lookat) would work. Best solution is to re-do the model. If that is not possible for any reason, you could use CFrame.Angles
CFrame.new(pos, lookat) * CFrame.Angles(0,math.pi/2,0)
--or (I can never remember what direction this rotates)
CFrame.new(pos, lookat) * CFrame.Angles(0,math.pi*3/2,0)
Hi, put this in StarterCharacterScripts. You can customize the sensitivity of the position lerp and the angle lerp by changing 0.03 to any higher number if you want.
local RunService = game:GetService'RunService'
local Players = game:GetService'Players'
local LocalPlayer = Players.LocalPlayer
local Character = LocalPlayer.Character
local RootPart = Character:WaitForChild'HumanoidRootPart'
local PetOffset = Vector3.new(0, 0, 5)
wait(3)
local Pet = Instance.new("Part", Character)
Pet.Size = Vector3.new(2, 2, 3)
Pet.CFrame = CFrame.new(RootPart.Position + PetOffset)
Pet.Anchored = true
Pet.CanCollide = false
local Position = Pet.Position
local Angle = CFrame.new()
RunService.RenderStepped:Connect(function()
Position = Position:Lerp(RootPart.Position + PetOffset + Vector3.new(0, math.sin(tick() * 5 % math.pi * 2), 0), 0.03)
local LookAt = CFrame.new(Pet.Position, RootPart.Position) * CFrame.Angles(math.rad(math.cos(tick() * 5 % math.pi * 2)) * 30, 0, 0)
LookAt = LookAt - LookAt.p
Angle = Angle:Lerp(LookAt, 0.03)
Pet.CFrame = CFrame.new(Position) * Angle
end)
Yes! That works! but I just don’t know how to make it only rotate on the X and Y-axis though. I tried only using X and Y on the CFrame.Angles() but this happens.