I want to change the fall animation in the roblox animate script to my own animation. The problem is, when I jump and start falling, the fall animation plays, and its kind of obnoxious I guess? Like your flailing your arms and stuff, and I don’t want that to happen every time you jump. I just want it to play after you have been falling for a while.
Attempted Solutions:
-Tried to script my own detection method, went horribly, if you have any ideas for that, do share
-Made the like easing parameter of the :Play() function 1 second, but the falling backwards of the falling animation is still visible (should I just make it longer than 1 second, or…?)
Assuming you correctly forked the animate script and didn’t overlay a new script on top of it, change your Weight and FadeTime parameters to your animation. Make sure the priority is also Movement.
local player = game.Players.LocalPlayer
local char = player.Character or player.CharacterAdded:Wait()
local hum = char:WaitForChild("Humanoid")
local animation = script:WaitForChild("Laughing") -- change to your PathToAnimation
local animator = hum:WaitForChild("Animator")
local load = animator:LoadAnimation(animation)
load.Priority = Enum.AnimationPriority.Action
load.Looped = true
local truefalling = false
local waittime = 0.4 -- change to how many secs to wait till animate, consider your player's jump height or jump power
hum.StateChanged:Connect(function(oldState,newState)
if newState == Enum.HumanoidStateType.Jumping or newState == Enum.HumanoidStateType.Freefall then
if not truefalling then
task.wait(waittime)
if hum:GetState() == Enum.HumanoidStateType.Freefall then
truefalling = true
load:Play()
end
end
elseif newState == Enum.HumanoidStateType.Landed then
truefalling = false
load:Stop()
end
end)
what if you jumped, so it knew you were in freefall, and then you jumped again right before waittime expired? it would then detect you as still freefalling, and play the animation, right…?
PathToAnimation is if you have an animation instance somewhere, for example if your animation is in workspace, the path would be workspace:WaitForChild(“MyCustomAnimation”). If you have an animation ID instead and using a script to make a new instance of animation, then you can define it there. local animation = PathToAnimation is the variable to where the animation is.
I just tested clicking space while falling and it still plays the animation. The script is waiting the waittime and checking if you are still freefalling, if you are, then the animation can play.
You can play around with the waittime. If they jump and land quickly, the animation won’t play because of the waittime and landing will reset the debounce.
Easy (And probably the best way) to do this is to playtest the game, go into your character and grab the Animate localscript, then copy-paste it into StarterCharacterScripts and then change the animationID for falling.
It works, but then when player is just coming down from a short jump, the custom animation is playing. OP wanted the animation to play only if they’re really falling from high place.
no, i mean that when you jump and land, it detected you freefalling for just a second, enough to trigger the freefalling event and start the waittime, then when you jump again before waittime ends it would still detect you as freefalling and play the animation
for example, lets say waittime was 10
if you jumped, it’d detect you freefalling for just a second, and start the waittime
so you stand there, and at 9 seconds on the clock, you jump, so then after the waittime is up, it checks your humanoidstate - and because you just jumped, it detects it as freefalling
pretty sure you would then land, and it would stop playing the animation, so it wouldnt be a huge bug, but it would still functionally act the same way as just changing the id, right? as it still would play it occasionally while falling after you jumped?
EDIT: Also, wouldn’t playing the animation on the client not replicate to the server? Or do I misunderstand…?
How does animation replication work client → server wise and vice versa?
I changed it a bit. Changed it using tick() and delay and only using the humanoid:getstate of freefall only.
local player = game.Players.LocalPlayer
local char = player.Character or player.CharacterAdded:Wait()
local hum = char:WaitForChild("Humanoid")
local animation = script:WaitForChild("laydown")
local animator = hum:WaitForChild("Animator")
local load = animator:LoadAnimation(animation)
load.Priority = Enum.AnimationPriority.Action
load.Looped = true
local delaytime = 0.5
local start -- create a variable with no value yet
hum.StateChanged:Connect(function(oldState,newState)
if newState == Enum.HumanoidStateType.Freefall then
start = tick() -- returns a current starting time value
delay(delaytime,function()
if tick() - start >= delaytime and hum:GetState() == Enum.HumanoidStateType.Freefall then
load:Play()
end
end)
elseif hum:GetState() ~= Enum.HumanoidStateType.Freefall then
load:Stop()
end
end)
interesting, are you able to explain why, or do you not fully know?
EDIT: also, last question - it works, but only before you die. if you die, it never works again
i moved it to startercharacterscripts and it seems to fix that problem and still work fine - are there any unforeseen issues that i dont know about that tells me i shouldnt use startercharacterscripts, or should it be fine?
Since the Animator is created automatically when a player joins and not added later by the client, then yes, it should be able to replicate to all clients and server.
It should be fine since the player only joins in once. The Character rejoins everytime it dies and not leave the game. Also, the regular Animate in the character is also a localscript.