#Idle animation
35 messages · Page 1 of 1 (latest)
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.
oh sorry, i just saw your message
** You are now Level 1! **
i can provide you with anything u need brother
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)
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)
it doesnt work as it should
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
i recorded it
now im sending
i just thought that maybe you just have to make smth like
if Humanoid.WalkSpeed == 0 then
idleanim:Play()
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)
You can
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)
hm
Although this may only let them crouch if standing still
Try the other one I sent first
i used this now
and look what it does
this doesnt work at all, character doesnt crouch
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
maybe i can make collaborate with you and u can just do it for yourself?
cause u understand more than me
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.
ok thank you!
** You are now Level 2! **
have a nice day
Of course, sorry I couldn’t be of more assistance.
nah friend, its ok