Hi, I can't Figure out what's wrong with my code. any help would be great!

local NewPet = script.Parent

NewPet.CanCollide = false

local PetPos = Instance.new("BodyPosition", NewPet)
local PetGyro = Instance.new("BodyGyro", NewPet)
PetGyro.MaxTorque = Vector3.new(400000,400000,400000)
local Owner = 'Pigred72'

while (1) do
	wait()
	local OwnerObj = workspace:WaitForChild(Owner)
	local OwnerPos = OwnerObj.HumanoidRootPart.Position
	local StopAt = ((OwnerObj - NewPet.Position).magnitude - 5) * 1000
	PetPos.P = StopAt
	PetPos.Position = OwnerPos + Vector3.new(0,10,0)
	PetGyro.CFrame = OwnerObj.HumanoidRootPart.CFrame
end

2 comments

0

What exactly is going wrong?

0

The pet just lies on the ground