I’m trying to make the pet lag behind the player
Into a smooth tween-ish kinda motion but it just isn’t working!
local player = Players.LocalPlayer
local character = player.Character or workspace:WaitForChild(player.Name, 5)
-- add onto pet instance
-- add onto pet instance
local pet = Instance.new("Part")
pet.Name = "Pet"
pet.Size = Vector3.new(3, 3, 3)
pet.Parent = character
pet.Transparency = 1
pet.Anchored = true
pet.CanCollide = false
local decal1 = Instance.new("Decal")
decal1.Parent = pet
decal1.Texture = "http://www.roblox.com/asset/?id=11598963797"
local decal2 = Instance.new("Decal")
decal2.Parent = pet
decal2.Texture = "http://www.roblox.com/asset/?id=11598963797"
while wait() do
for i = 0, 1, 0.01 do
wait()
local petCframe = pet.PrimaryPart.CFrame
local characterCframe = character.PrimaryPart.CFrame
local targetCframe = characterCframe:ToWorldSpace(CFrame.new(3,1,0))
local newCframe = petCframe:Lerp(targetCframe, i)
pet:SetPrimaryPartCFrame(newCframe)
end
end```
Try using Body Movers such as, BodyPosition or BodyForce, although they are deprecated they still work perfectly but if you want to use an updated version use VectorLine I believe.
Another thing you can use is TweenService,
Not totally sure how well that would work though.
Also instead of using wait() use task.wait() its faster
This is the code I use to make my pets move: function movePet()
local pet = pet:FindFirstChild(“PrimaryPart”)
if pet ~= nil then
if pet:FindFirstChild(“HumanoidRootPart”) ~= nil then
local speed = pet.HumanoidRootPart:FindFirstChild(“Speed”)
local primaryPart = pet.PrimaryPart
local humanoidRootPart = pet.HumanoidRootPart
if primaryPart ~= nil and humanoidRootPart ~= nil then
local c = primaryPart.CFrame
local player = Players.LocalPlayer
local character = player.Character or player.CharacterAdded:Wait()
local humanoid = character:FindFirstChild(“Humanoid”)
if humanoid ~= nil then
local goal = humanoidRootPart.CFrame
local goalDirection = (goal.p - c.p).unit
local goalDistance = (goal.p - c.p).magnitude
local goalAngle = ((goal - c).lookVector).unit
local goalEuler = (goal - c).lookVector.unit
local x = goalDirection.X
local y = goalDirection.Y
local z = goalDirection.Z
if speed ~= nil then
if goalDistance >= speed.Value then
humanoidRootPart.Velocity = Vector3.new(x * speed.Value, y * speed.Value, z * speed.Value)
else
humanoidRootPart.Velocity = Vector3.new(x * goalDistance, y * goalDistance, z * goalDistance)
end
end
end
end
end
end
end