Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- repeat wait() until script.Parent:FindFirstChild("Pet")
- local hrp = script.Parent.HumanoidRootPart
- local moveAnim = script.Parent.Pet.Humanoid:LoadAnimation(script.Parent.Pet.Walking)
- game:GetService("RunService").Heartbeat:Connect(function()
- local ray = Ray.new(script.Parent.Pet.HumanoidRootPart.Position, -script.Parent.Pet.HumanoidRootPart.CFrame.UpVector * 1000)
- local part = workspace:FindPartOnRayWithIgnoreList(ray, {script.Parent})
- local groundY = part.Position.Y + (part.Size.Y / 2)
- local goalCF = hrp.CFrame + Vector3.new(0, groundY + 0.95 - hrp.Position.Y, 0) - (hrp.CFrame.RightVector + hrp.CFrame.LookVector) * 2
- script.Parent.Pet.HumanoidRootPart.BodyPosition.Position = goalCF.Position
- script.Parent.Pet.HumanoidRootPart.BodyGyro.CFrame = goalCF
- if script.Parent.HumanoidRootPart.Velocity.Magnitude > 10 then
- if not moveAnim.IsPlaying then moveAnim:Play() end
- else
- moveAnim:Stop()
- end
- end)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement