I want make the character play a animation after falling
For some reason they still able to jump after fall and I don’t know why
I try make more variables or change “JumpPower” first but don’t work
Video Showing the error:
No! the output don’t show any message of error!
Code:
local UserInputService = game:GetService("UserInputService")
local character = script.Parent
local EndRun = Instance.new("Animation")
EndRun.AnimationId = "rbxassetid://12610422791"
local EndFall = Instance.new("Animation")
EndFall.AnimationId = "rbxassetid://12610426725"
local humanoid = character:WaitForChild("Humanoid")
local loadedrun = humanoid:LoadAnimation(EndRun)
local loadedfall = humanoid:LoadAnimation(EndFall)
humanoid.BreakJointsOnDeath = false
humanoid.StateChanged:Connect(function(_oldState, newState)
print(_oldState)
print(newState)
if newState == Enum.HumanoidStateType.Landed and _oldState == Enum.HumanoidStateType.Freefall or newState == Enum.HumanoidStateType.Running and _oldState == Enum.HumanoidStateType.Freefall or newState == Enum.HumanoidStateType.Running and _oldState == Enum.HumanoidStateType.Landed then
humanoid.WalkSpeed = 2
humanoid.JumpPower = 0
loadedfall:Play()
loadedfall.Stopped:Wait()
humanoid.WalkSpeed = 20
humanoid.JumpPower = 60
elseif newState == Enum.HumanoidStateType.Jumping then
humanoid.WalkSpeed = 25
task.wait(0.2)
if newState == Enum.HumanoidStateType.Freefall then
humanoid.WalkSpeed = 18
end
end
end)
If you’ve solved your own problem, I would suggest replying with the solution and marking it as such. That way the forum can tell that your solution is actually solved and perhaps help others in the future when looking for answers.
local canQuickStop = false
local minspeed = 24 -- Set this to the minimum running speed required for a stop animation to play.
local humanoid = script.Parent:WaitForChild("Humanoid", nil)
humanoid.FallingDown:Connect(function(active)
if active then
canQuickStop = false
local speed = humanoid.Running:Wait()
if speed > minspeed then
canQuickStop = true
end
end
end)
humanoid.Jumping:Connect(function(active)
if active then
canQuickStop = false
end
end)
humanoid.Running:Connect(function(speed)
if speed == 0 and script.Parent.Humanoid.WalkSpeed > minspeed then
if canQuickStop then
canQuickStop = false
local qsanim = script.Parent.Humanoid:LoadAnimation(script.Quickstop)
qsanim:Play()
qsanim:AdjustSpeed(math.random(1,1.5))
-- game:GetService("HapticService"):SetMotor(Enum.UserInputType.Gamepad1, Enum.VibrationMotor.Large, .5)
script.Parent.Humanoid:SetStateEnabled(Enum.HumanoidStateType.Jumping, false)
script.Parent.Humanoid:SetStateEnabled(Enum.HumanoidStateType.Running, false)
qsanim.Stopped:Connect(function()
--game:GetService("HapticService"):SetMotor(Enum.UserInputType.Gamepad1, Enum.VibrationMotor.Large, 0)
script.Parent.Humanoid:SetStateEnabled(Enum.HumanoidStateType.Jumping, true)
script.Parent.Humanoid:SetStateEnabled(Enum.HumanoidStateType.Running, true)
end)
end
elseif speed > minspeed then
canQuickStop = true
end
end)