Hello, there.
I am having a hard time getting this pet movement system to work. It’s using :lerp() instead of body movers.
The issue I’m having, is that the pet just falls through the ground and eventually disappears into nothingness. I checked the rotation on it though, and that part seems to work as intended.
Already tried setting network owner to the local player, and idk what else to try.
Here’s the code (localscript):
RunService.RenderStepped:Connect(function(step)
for i,player in next, game.Players:GetPlayers() do
local Character = player.Character
if Character then
if Character:FindFirstChild("Pets") then
local hrp = Character:FindFirstChild("HumanoidRootPart")
local humanoid = Character:FindFirstChild("Humanoid")
if hrp and humanoid then
local list = {}
for i,GamePet in next, Character:WaitForChild("Pets"):GetChildren() do
table.insert(list,GamePet)
end
for i,pet in next, list do
local newpos = hrp.CFrame.p
local cf = CFrame.new(newpos)
cf = cf * CFrame.Angles(0,math.rad((360/player.PlayerData.PetFolder.NumberEquipped.Value)*i),0)
if player.PlayerData.PetFolder.NumberEquipped.Value <= 8 then
cf = cf + (cf.lookVector * (7)) + Vector3.new(0, 0,0)
else
cf = cf + (cf.lookVector * (player.PlayerData.PetFolder.NumberEquipped.Value - 1)) + Vector3.new(0,.5*math.sin(tick()),0)
end
cf = CFrame.new(cf.p,cf.p + hrp.CFrame.lookVector)
if humanoid.MoveDirection == Vector3.new(0,0,0) then
cf = CFrame.new(cf.p, hrp.CFrame.p)
end
--Cf = Cf:lerp(newcf, .1)
cf = cf * CFrame.new(0, 0.66 * math.sin(tick()), 0)
local new = pet.PrimaryPart.CFrame:lerp(cf,.1)
pet:SetPrimaryPartCFrame(new)
end
end
end
end
end
end)
If anyone could possibly help me out here, that’d be great
Thank you!