#Having trouble with crawling animation
1 messages · Page 1 of 1 (latest)
** You are now Level 1! **
Can you give me the full code?
local crawlIdle = script:WaitForChild("CrawlIdle")
local player = script.Parent
local humanoid = player:WaitForChild("Humanoid")
local idleTrack = humanoid:LoadAnimation(crawlIdle)
local UIS = game:GetService("UserInputService")
UIS.InputBegan:Connect(function(input,gameProcessedEvent)
if (UIS:IsKeyDown(Enum.KeyCode.LeftShift)) == true then
idleTrack:Play()
print("Player is crawling")
end
end)
UIS.InputEnded:Connect(function(input,gameProcessedEvent)
if (UIS:IsKeyDown(Enum.KeyCode.LeftShift)) == not true then
idleTrack:Stop()
print("Player has stopped crawling")
end
end)```
you mean like that?
Are you just gonna toss the code into ChatGpt?
💀
ssuurree....
for future reference, not true can be written as false
Oh my god thank you
I giggled non offensively
Don't worry, I did too
Looking at this, InputEnded will fire for any input whatsoever.
So if the LeftShift is not pressed when an input ends (key is released) it'll still run that code
love that
Interesting
I'm not sure what to do to get around that 😭
I'm really new to coding but I guess I'll play around and see if I can find something that works
add this:
if input.KeyCode == Enum.KeyCode.LeftShift then
--- your other code inside here
end
into your input detection events
or, just the last one really
I don't know where you want me to put that-
replacing (UIS:IsKeyDown(Enum.KeyCode.LeftShift)) == false with input.KeyCode == Enum.KeyCode.LeftShift has the same result
oh wait
well, your code should just work even without that
tbh you dont even need it
I mean it DOES
that's a fine place to add it tho, i suppose
but I don't want "Player has stopped crawling" to constantly print
** You are now Level 2! **
I feel like that's gonna cause a problem or something later down the line
Does printing cause lag at all?
hmm. should be fine for the most part
only in studio if you print too much, not ingame
unless you open the dev console lol but no its fine
I deleted the suffix to UIS.Input 💀
when did I even-
not true 😭
Annnndddd it has, I think
Oh wait nvm I might be able to fix it
Unsure
I made a crawling animation for when the player moves, but it doesn't stop when I let go of WASD
local crawlMove = script:WaitForChild("CrawlMove")
local player = script.Parent
local humanoid = player:WaitForChild("Humanoid")
local idleTrack = humanoid:LoadAnimation(crawlIdle)
local moveTrack = humanoid:LoadAnimation(crawlMove)
local UIS = game:GetService("UserInputService")
local moveCheck = false
UIS.InputBegan:Connect(function(input,gameProcessedEvent)
local keyW = input.KeyCode == Enum.KeyCode.W
local keyA = input.KeyCode == Enum.KeyCode.A
local keyS = input.KeyCode == Enum.KeyCode.S
local keyD = input.KeyCode == Enum.KeyCode.D
if (UIS:IsKeyDown(Enum.KeyCode.LeftShift)) == true then
idleTrack:Play(0.2)
if humanoid then
humanoid.WalkSpeed = 8
end
end
if keyW and (UIS:IsKeyDown(Enum.KeyCode.LeftShift)) == true then
moveCheck = true
end
if keyA and (UIS:IsKeyDown(Enum.KeyCode.LeftShift)) == true then
moveCheck = true
end
if keyS and (UIS:IsKeyDown(Enum.KeyCode.LeftShift)) == true then
moveCheck = true
end
if keyD and (UIS:IsKeyDown(Enum.KeyCode.LeftShift)) == true then
moveCheck = true
end
if moveCheck == true then
moveTrack:Play()
end
end)
UIS.InputEnded:Connect(function(input,gameProcessedEvent)
local keyW = input.KeyCode == Enum.KeyCode.W
local keyA = input.KeyCode == Enum.KeyCode.A
local keyS = input.KeyCode == Enum.KeyCode.S
local keyD = input.KeyCode == Enum.KeyCode.D
if UIS:IsKeyDown(Enum.KeyCode.LeftShift) == false then
idleTrack:Stop(0.2)
moveCheck = false
if humanoid then
humanoid.WalkSpeed = 13
end
end
if keyW and keyA and keyS and keyD == false then
moveCheck = false
end
if moveCheck == false then
moveTrack:Stop()
end
end)```
hmm
apparently moveCheck only goes false when I let go of LShift, interesting
the animation also restarts every time I make another input 😭
Imma try something
Oh wait I'm actually so stupid