--local Anim = script.Parent.AnimationController:LoadAnimation(game.ReplicatedStorage.Pets.Settings.WalkAnim)
--local AnimPlay = false


if Player then
	while wait() do
		if Player.Character:FindFirstChild("HumanoidRootPart") then
			local Pos = script.Parent.Pos.Value
			local CoinPos = script.Parent.CoinPos.Value
			local BG = script.Parent.BodyGyro
			local BP = script.Parent.BodyPosition
			local d = Player.Character.HumanoidRootPart.Position.Y - script.Parent.Position.Y
			if script.Parent.Selected.Value == 0 then
				local Stats = require(game.ReplicatedStorage.Assets.Pets:FindFirstChild(script.Parent.PetName.Value)["Pet Data"])
				if Stats.fly == true then
					BP.Position = (Player.Character.HumanoidRootPart.Position + Pos) - Vector3.new(0,2,0) + Vector3.new(0,script.Parent.Size.Y/2,0) + Vector3.new(0, game.ServerScriptService.globalPetFloat.Value, 0)
					if Player.Walking.Value == false then
						BG.CFrame = CFrame.new(script.Parent.Position, Player.Character.HumanoidRootPart.Position - Vector3.new(0, d, 0))
					else
						BG.CFrame = Player.Character.HumanoidRootPart.CFrame
					end
				else
					BP.Position = (Player.Character.HumanoidRootPart.Position + Pos) - Vector3.new(0,3.4,0) + Vector3.new(0,script.Parent.Size.Y/2,0)
					if Player.Walking.Value == false then
						BG.CFrame = CFrame.new(script.Parent.Position, Player.Character.HumanoidRootPart.Position - Vector3.new(0, d, 0))
					else
						BG.CFrame = Player.Character.HumanoidRootPart.CFrame
					end
				end
			else
				BP.Position = (workspace.CoinFolder[script.Parent.Selected.Value].Position + CoinPos) - Vector3.new(0,workspace.CoinFolder[script.Parent.Selected.Value].Size.Y/2,0) + Vector3.new(0,script.Parent.Size.Y/2,0)
				BG.CFrame = CFrame.new(script.Parent.Position, workspace.CoinFolder[script.Parent.Selected.Value].Position - Vector3.new(0, 0, 0))
			end
		end
	end
end
