Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

How do i make my pet an floating animation when player is not moving?

Asked by
DashDQ 17
3 years ago

So this is the script i have but don't know how to make so when the player doesn't move the pet still bounces a bit in the air.

local pet = script.Parent

function givePet (player)
    if player then
        local character = player.Character
        if character then
            local humRootPart = character.HumanoidRootPart
            local newPet = pet:Clone ()
            newPet.Parent = character

            local bodyPos = Instance.new("BodyPosition", newPet)
            bodyPos.MaxForce = Vector3.new(math.huge, math.huge, math.huge)

            local bodyGyro = Instance.new("BodyGyro", newPet)
            bodyGyro.MaxTorque = Vector3.new(math.huge, math.huge, math.huge)


            newPet.CanCollide = false

            while wait() do
                bodyPos.Position = humRootPart.Position + Vector3.new(3, 3, 4)
                bodyGyro.CFrame = humRootPart.CFrame
            end

        end
    end
end

game.Players.PlayerAdded:Connect(function(player)
    player.CharacterAdded:Connect(function(char)
        givePet(player)
    end)
end)
0
Anyone can help me? DashDQ 17 — 3y

Answer this question