Hey there, I want to move this pet smoothly, can anyone help me?
here is the script
local tweenService = game:GetService("TweenService")
local char = script.Parent.Parent.Parent
local hum = char:FindFirstChild("Humanoid")
local HumanoidRootPart = char:FindFirstChild("HumanoidRootPart")
local pet = script.Parent
while wait() do
local goal = {}
goal.CFrame = HumanoidRootPart.CFrame + Vector3.new(3,1,3)
local tweenInfo = TweenInfo.new(0.01, Enum.EasingStyle.Linear, Enum.EasingDirection.In,0,false,0.01)
print(pet.CFrame)
local tween = tweenService:Create(pet,tweenInfo,goal)
print(tween)
tween:Play()
end
while wait(1) do
local goal = {}
goal.CFrame = HumanoidRootPart.CFrame + Vector3.new(3,1,3)
local tweenInfo = TweenInfo.new(1, Enum.EasingStyle.Sine, Enum.EasingDirection.InOut)
--[[ I've changed these properties to make it look smoother (Linear to Sine, In to InOut),
and changed the time from 0.01 to 1
--]]
print(pet.CFrame)
local tween = tweenService:Create(pet,tweenInfo,goal)
print(tween)
tween:Play()
end
local tweenService = game:GetService("TweenService")
local char = script.Parent.Parent.Parent
local hum = char:FindFirstChild("Humanoid")
local HumanoidRootPart = char:FindFirstChild("HumanoidRootPart")
local pet = script.Parent
while wait() do
local goal = {}
goal.CFrame = HumanoidRootPart.CFrame + Vector3.new(3,1,3)
wait(0.01)
local tweenInfo = TweenInfo.new(0.11, Enum.EasingStyle.Sine, Enum.EasingDirection.InOut,-30,false,0.01)
--[[ I've changed these properties to make it look smoother (Linear to Sine, In to InOut),
and changed the time from 0.01 to 1
--]]
print(pet.CFrame)
local tween = tweenService:Create(pet,tweenInfo,goal)
print(tween)
tween:Play()
end
local goal = {}
goal.CFrame = HumanoidRootPart.CFrame + Vector3.new(3,1,3)
wait(0.05)
local tweenInfo = TweenInfo.new(0.05, Enum.EasingStyle.Back, Enum.EasingDirection.InOut)
--[[ I've changed these properties to make it look smoother (Linear to Sine, In to InOut),
and changed the time from 0.01 to 1
--]]
print(pet.CFrame)
local tween = tweenService:Create(pet,tweenInfo,goal)
print(tween)
tween:Play()
Only if you want physics to apply to the Pet. If it gets stuck you’ll need to teleport it if the pet gets too far away.
As a tip for tween service you should be calculating the time based on distance and speed. This is so the pet moves consistently regardless of distance if you continue to use TweenService.
Time = Distance/Speed
Distance will be the magnitude between the player and pet.
Speed you’ll have to tweak until you get the value you want.
BodyPosition can be used despite gravity, and if getting stuck is a real problem then it doesn’t hurt to turn collisions off for the pet because no one should be interacting with it anyway if its considered cosmetic of course.
It seems like you are doing it on the server, which can cause some latency, try doing it in a local script instead(client sided). And like others suggested, try using body movers if that doesn’t work.