#Idle animation

35 messages · Page 1 of 1 (latest)

ocean jolt
#

Can you provide the script?

#

If not, my suggestion is make a boolean (true/false var) and set it to true on initialization. If they are crouching, set it to false and stop the idle animation. If they’re not crouching, set it to true and stop the crouch animation and play the idle again. I assume you want the play to begin in the idle position.

sterile tartan
jolly krakenBOT
#

studio** You are now Level 1! **studio

sterile tartan
#

i can provide you with anything u need brother

sterile tartan
# ocean jolt Can you provide the script?

local TweenService = game:GetService("TweenService")
local Humanoid = game:GetService("Players").LocalPlayer.Character:WaitForChild("Humanoid")
local HumanoidRootPart = game:GetService("Players").LocalPlayer.Character:WaitForChild("HumanoidRootPart")

local CrouchAnimation = script.CrouchAnimation
local CrouchTrack = Humanoid:LoadAnimation(CrouchAnimation)

local CameraInfo = TweenInfo.new(
0.3,
Enum.EasingStyle.Quint,
Enum.EasingDirection.Out,
0,
false,
0
)

local CrouchedGoal = {CameraOffset = Vector3.new(0,-1.2,-0.5)}
local UncrouchedGoal = {CameraOffset = Vector3.new(0,0,0)}

local CrouchedTween = TweenService:Create(Humanoid, CameraInfo, CrouchedGoal)
local UncrouchedTween = TweenService:Create(Humanoid, CameraInfo, UncrouchedGoal)

local inCrouch = false

local function Crouch()
if inCrouch == false then
inCrouch = true
CrouchedTween:Play()
Humanoid.WalkSpeed = 8
CrouchTrack:Play()

    HumanoidRootPart.CanCollide = false

else
    inCrouch = false
    UncrouchedTween:Play()
    Humanoid.WalkSpeed = 16
    CrouchTrack:Stop()

    HumanoidRootPart.CanCollide = true

end

end

game:GetService("UserInputService").InputBegan:Connect(function(input)
if input.KeyCode == Enum.KeyCode.LeftControl then
Crouch()
end
end)

ocean jolt
#
local TweenService = game:GetService("TweenService")
local Humanoid = game:GetService("Players").LocalPlayer.Character:WaitForChild("Humanoid")
local HumanoidRootPart = game:GetService("Players").LocalPlayer.Character:WaitForChild("HumanoidRootPart")

local CrouchAnimation = script.CrouchAnimation
local IdleAnimation = script.IdleAnimation -- Added reference to idle animation
local CrouchTrack = Humanoid:LoadAnimation(CrouchAnimation)
local IdleTrack = Humanoid:LoadAnimation(IdleAnimation) -- Created track for idle animation

local CameraInfo = TweenInfo.new(
    0.3,
    Enum.EasingStyle.Quint,
    Enum.EasingDirection.Out,
    0,
    false,
    0
)

local CrouchedGoal = {CameraOffset = Vector3.new(0,-1.2,-0.5)}
local UncrouchedGoal = {CameraOffset = Vector3.new(0,0,0)}

local CrouchedTween = TweenService:Create(Humanoid, CameraInfo, CrouchedGoal)
local UncrouchedTween = TweenService:Create(Humanoid, CameraInfo, UncrouchedGoal)

local inCrouch = false

local function Crouch()
    if inCrouch == false then
        inCrouch = true
        CrouchedTween:Play()
        Humanoid.WalkSpeed = 8
        CrouchTrack:Play()

        HumanoidRootPart.CanCollide = false

    else
        inCrouch = false
        UncrouchedTween:Play()
        Humanoid.WalkSpeed = 16
        CrouchTrack:Stop()

        HumanoidRootPart.CanCollide = true
        IdleTrack:Play() -- Play idle animation when not crouching

    end
end

game:GetService("UserInputService").InputBegan:Connect(function(input)
    if input.KeyCode == Enum.KeyCode.LeftControl then
        Crouch()
    end
end)
sterile tartan
#

it doesnt work as it should

ocean jolt
#

Add print statements and debug as needed

#

“It doesn’t work” isn’t really much to go on

#

What specifically doesn’t work? Provide more details

sterile tartan
ocean jolt
#

Try this;


local TweenService = game:GetService("TweenService")
local Players = game:GetService("Players")
local UserInputService = game:GetService("UserInputService")

local player = Players.LocalPlayer
local Character = player.Character or player.CharacterAdded:Wait()
local Humanoid = Character:WaitForChild("Humanoid")
local HumanoidRootPart = Character:WaitForChild("HumanoidRootPart")

local IdleAnimationId = "rbxassetid://123456789" -- Replace this with the ID of your idle animation
local CrouchAnimation = script.CrouchAnimation

local IdleAnimation = Instance.new("Animation")
IdleAnimation.AnimationId = IdleAnimationId
local IdleTrack = Humanoid:LoadAnimation(IdleAnimation)
IdleTrack.Looped = true
IdleTrack:Play()

local CrouchTrack = Humanoid:LoadAnimation(CrouchAnimation)

local CameraInfo = TweenInfo.new(
    0.3,
    Enum.EasingStyle.Quint,
    Enum.EasingDirection.Out,
    0,
    false,
    0
)

local CrouchedGoal = {CameraOffset = Vector3.new(0,-1.2,-0.5)}
local UncrouchedGoal = {CameraOffset = Vector3.new(0,0,0)}

local CrouchedTween = TweenService:Create(Humanoid, CameraInfo, CrouchedGoal)
local UncrouchedTween = TweenService:Create(Humanoid, CameraInfo, UncrouchedGoal)

local inCrouch = false

local function Crouch()
    if inCrouch == false then
        inCrouch = true
        IdleTrack:Stop()
        CrouchedTween:Play()
        Humanoid.WalkSpeed = 8
        CrouchTrack:Play()

        HumanoidRootPart.CanCollide = false

    else
        inCrouch = false
        IdleTrack:Play()
        UncrouchedTween:Play()
        Humanoid.WalkSpeed = 16
        CrouchTrack:Stop()

        HumanoidRootPart.CanCollide = true

    end
end

UserInputService.InputBegan:Connect(function(input)
    if input.KeyCode == Enum.KeyCode.LeftControl then
        Crouch()
    end
end)
ocean jolt
#

local TweenService = game:GetService("TweenService")
local Players = game:GetService("Players")
local UserInputService = game:GetService("UserInputService")

local player = Players.LocalPlayer
local Character = player.Character or player.CharacterAdded:Wait()
local Humanoid = Character:WaitForChild("Humanoid")
local HumanoidRootPart = Character:WaitForChild("HumanoidRootPart")

local CrouchAnimation = script.CrouchAnimation
local IdleAnimation = script.IdleAnimation

local CrouchTrack = Humanoid:LoadAnimation(CrouchAnimation)
local IdleTrack = Humanoid:LoadAnimation(IdleAnimation)
IdleTrack.Looped = true

local CameraInfo = TweenInfo.new(
    0.3,
    Enum.EasingStyle.Quint,
    Enum.EasingDirection.Out,
    0,
    false,
    0
)

local CrouchedGoal = {CameraOffset = Vector3.new(0,-1.2,-0.5)}
local UncrouchedGoal = {CameraOffset = Vector3.new(0,0,0)}

local CrouchedTween = TweenService:Create(Humanoid, CameraInfo, CrouchedGoal)
local UncrouchedTween = TweenService:Create(Humanoid, CameraInfo, UncrouchedGoal)

local function Crouch()
    if Humanoid.WalkSpeed == 0 then
        IdleTrack:Play()
    else
        IdleTrack:Stop()
    end
end

UserInputService.InputBegan:Connect(function(input)
    if input.KeyCode == Enum.KeyCode.LeftControl then
        Crouch()
    end
end)
sterile tartan
#

hm

ocean jolt
#

Although this may only let them crouch if standing still

#

Try the other one I sent first

sterile tartan
ocean jolt
#

Yeah, I’m not sure then. I’m not versed in animation scripts whatsoever. I would recommend looking on forums and/or looking at documentation some more

sterile tartan
#

maybe i can make collaborate with you and u can just do it for yourself?

#

cause u understand more than me

ocean jolt
#

I can’t right now, I’m not on my desktop. Also, as I said, I don’t utilize animation in my scripts. I would recommend finding an actual animation scripter to ask.

sterile tartan
#

ok thank you!

jolly krakenBOT
#

studio** You are now Level 2! **studio

sterile tartan
#

have a nice day

ocean jolt
#

Of course, sorry I couldn’t be of more assistance.

sterile tartan