The pet is position is changing (goes to the front of the player then back of the player)

Here is a vid of the prob.

Here is the code

local tweenService = game:GetService("TweenService")
local char = script.Parent.Parent.Parent
local HumanoidRootPart = char:WaitForChild("HumanoidRootPart")
local pet = script.Parent



while wait() do
	local goal = {}
	goal.CFrame = HumanoidRootPart.CFrame + Vector3.new(5,1,5)
	local tweenInfo = TweenInfo.new(0.1, Enum.EasingStyle.Back, Enum.EasingDirection.InOut) 
	print(pet.CFrame)
	local tween = tweenService:Create(pet,tweenInfo,goal)
	print(tween)
	tween:Play()
 end
1 Like

Vector3 values do not account for rotation, whereas CFrame values account for both position and rotation. Therefore, you should define the offset as a CFrame and multiply (essentially the same as adding for CFrames) the values so that the pet’s position remains relative to the player.

goal.CFrame = HumanoidRootPart.CFrame * CFrame.new(5, 1, 5)
4 Likes