I’m trying to update a pets position, however when they spawn in they do not move. All parts are unanchored on the pet.
local SpawnedPetModel = Assets.Pets[PetData.ModelName]:Clone()
local AlignPosition = Instance.new("AlignPosition")
AlignPosition.Mode = Enum.PositionAlignmentMode.OneAttachment
AlignPosition.Parent = SpawnedPetModel.PrimaryPart
SpawnedPetModel.Parent = workspace.ActivePets
SpawnedPetModel.PrimaryPart:SetNetworkOwner(player)
RunService.RenderStepped:Connect(function()
if not Player.Character then return end
if not Player.Character:FindFirstChild("HumanoidRootPart") then return end
local HumanoidCFrame = Player.Character.HumanoidRootPart:GetPivot()
for petIndex, activePet in pairs(self.ActivePets) do
if Player:GetAttribute("Status") == "Land" then
local PetPosition = (HumanoidCFrame * CFrame.new(PET_OFFSETS[petIndex])).Position
-- Raycast then handle the result
local Raycast = workspace:Raycast(
PetPosition + Vector3.new(0, 15, 0),
Vector3.new(0, -30, 0),
Params
)
local NewPetPosition
if Raycast then
NewPetPosition = Raycast.Position
else
NewPetPosition = PetPosition - Vector3.new(0, Player.Character.Humanoid.HipHeight + 1.5, 0)
end
-- Lerp the position
local YOffset = -activePet.PetInstance.PrimaryPart.Floor.Position.Y + Pets[activePet.PetInstance.Name].AboveGroundY
local NewCFrame = CFrame.fromMatrix(NewPetPosition + Vector3.new(0, YOffset, 0), HumanoidCFrame.RightVector, HumanoidCFrame.UpVector)
local LerpCFrame = activePet.PetInstance.PrimaryPart.CFrame:Lerp(NewCFrame, 0.078)
activePet.PetInstance.PrimaryPart.AlignPosition.Position = LerpCFrame.Position
end
end
end)
Position updates, but the pet does not move at all