-
What do you want to achieve? Keep it simple and clear!
When my character sprints and jumps, i want the jump animation to play, and then the sprint animation when the player lands -
What is the issue? Include screenshots / videos if possible!
My current code works if the player jumps and lands sprint anim plays again, but the issue is when the player falls from a small height the sprint animation doesnt play but the character still sprints -
What solutions have you tried so far? Did you look for solutions on the Developer Hub?
I have tried getting humanoid state when running but it only works if falling from a height (character jumping)
code:
game:GetService("UserInputService").InputBegan:Connect(function(input) --gamerfortnite
if input.KeyCode == Enum.KeyCode.LeftShift and Humanoid.MoveDirection.Magnitude > 0 then
RunningTween:Play()
SprintAnim:Play(0.3)
Sprinting = true
repeat task.wait() until not game:GetService("UserInputService"):IsKeyDown(Enum.KeyCode.LeftShift) or Humanoid.MoveDirection.Magnitude <= 0
Sprinting = false
SprintAnim:Stop(0.2)
WalkingTween:Play()
end
end)
game:GetService('RunService').RenderStepped:Connect(function(dt)
local tool2b2t = Character:FindFirstChildWhichIsA("Tool")
if not tool2b2t and Sprinting == false then
game.ReplicatedStorage.Values.Springt.Value = false
elseif not tool2b2t and Sprinting == true then
Humanoid.WalkSpeed = 20
end
if Sprinting == true then
game.ReplicatedStorage.Values.Springt.Value = true
else
game.ReplicatedStorage.Values.Springt.Value = false
end
end)
Humanoid.StateChanged:Connect(function(old, new) -- You dont have to use these but we will
if new == Enum.HumanoidStateType.Running and Sprinting then
SprintAnim:Play()
elseif new ~= Enum.HumanoidStateType.Running then
SprintAnim:Stop()
end
end)
this is the whole code, not really important (i think), what is important is this:
Humanoid.StateChanged:Connect(function(old, new)
if new == Enum.HumanoidStateType.Running and Sprinting then
SprintAnim:Play()
elseif new ~= Enum.HumanoidStateType.Running then
SprintAnim:Stop()
end
end)
when the player jumps their state goes to jump, so i detect when it chagnes to run and is sprinting, but if u fall from a small height roblox doesnt change it because of delays im guessing, is there another way to detect if the player falls at all or something?