I am currently in the process of making a crouching system when the player clicks “c”, and my take on doing this is by changing the default animations in the roblox “animate” script (as shown in the code below) to the crouching set of animations. This works perfectly fine but the problem is the animations don’t take place until the character moves. I tried changing the humanoid state to see if that would update the animation and messing around in the animate script itself, but I can’t find a way to “update” the script to adapt to the new set of animations until the character moves. Please let me know if you are able to configure or call a function in the roblox animate script which would initiate the new set of animations without moving the character. Thanks!
local AnimKit = {}
local Animations = {
Regular = {Run = 507767714, Walk = 507777826, Jump = 507765000, Idle = 507766666, Idle2 = 507766951, Idle3 = 507766388, Fall = 507767968, Swim = 507784897, SwimIdle = 507785072, Climb = 507765644},
Crouching = {Run = 12028275301, Walk = 12028275301, Jump = 0, Idle = 12028237928, Idle2 = 12028318329, Idle3 = 0, Fall = 0, Swim = 0, SwimIdle = 0, Climb = 0},
}
function AnimKit.setAnim(Player, Animation)
if not Animations[Animation] then return false end
local Character = Player.Character or Player.CharacterAdded:Wait()
local Humanoid = Character:WaitForChild("Humanoid")
local HRP = Character:WaitForChild("HumanoidRootPart")
local AnimScript = Character:WaitForChild("Animate")
AnimScript.run.RunAnim.AnimationId = "rbxassetid://".. tostring(Animations[Animation].Run)
AnimScript.walk.WalkAnim.AnimationId = "rbxassetid://".. tostring(Animations[Animation].Walk)
AnimScript.jump.JumpAnim.AnimationId = "rbxassetid://".. tostring(Animations[Animation].Jump)
AnimScript.idle.Animation1.AnimationId = "rbxassetid://".. tostring(Animations[Animation].Idle)
AnimScript.idle.Animation2.AnimationId = "rbxassetid://".. tostring(Animations[Animation].Idle2)
AnimScript.swim.Swim.AnimationId = "rbxassetid://".. tostring(Animations[Animation].Swim)
AnimScript.swimidle.SwimIdle.AnimationId = "rbxassetid://".. tostring(Animations[Animation].SwimIdle)
AnimScript.fall.FallAnim.AnimationId = "rbxassetid://".. tostring(Animations[Animation].Fall)
AnimScript.climb.ClimbAnim.AnimationId = "rbxassetid://".. tostring(Animations[Animation].Climb)
end
return AnimKit
It might be cause the humanoids animator is looking for an animation that does not exist, and plays no animation until its called to play a new animation
be sure to play an animation on the animator the moment the Animate script updated(like an idle anim) to kick things off
local AnimKit = {}
local Animations = {
Regular = {run = 507767714, walk = 507777826, jump = 507765000, idle = {idle1 = 507766666, idle2 = 507766951, idle3 = 507766388}, fall = 507767968, swim = 507784897, swimidle = 507785072, climb = 507765644},
Crouching = {run = 12028275301, walk = 12028275301, jump = 507765000, idle = {idle1 = 12028237928, idle2 = 12028318329}, fall = 0, swim = 0, swimidle = 0, climb = 0},
}
function AnimKit.setAnim(Player, Animation)
if not Animations[Animation] then return false end
local Character = Player.Character or Player.CharacterAdded:Wait()
local Humanoid = Character:WaitForChild("Humanoid")
local HRP = Character:WaitForChild("HumanoidRootPart")
local AnimScript = Character:WaitForChild("Animate")
for Category, Id in pairs(Animations[Animation]) do
if AnimScript:FindFirstChild(Category) and Id ~= 0 then
for _, OldAnim in pairs(AnimScript[Category]:GetChildren()) do
OldAnim:Destroy()
end
if type(Id) == "table" then
for Anim, Id in pairs(Id) do
local NewAnim = Instance.new("Animation")
NewAnim.AnimationId = "rbxassetid://".. tostring(Id)
NewAnim.Name = Anim.. "Anim"
NewAnim.Parent = AnimScript[Category]
end
else
local NewAnim = Instance.new("Animation")
NewAnim.AnimationId = "rbxassetid://".. tostring(Id)
NewAnim.Name = Category.. "Anim"
NewAnim.Parent = AnimScript[Category]
end
end
end
end
return AnimKit
Even when deleting the animations and creating new ones, it acts the same as my original code.
Is the problem that the animations stop completely for a second and then switch? It might be from the AnimationTracks taking a second to load. It might be possible to preload them onto the humanoid, though I think it would just load another animation track with the same animation so that probably won’t work.
I’m not sure exactly what the problem is or how to fix it.
Assume I am standing still with the default roblox idle animation. Bassicley, when I change to the crouching\running and idle animations, unless I move, it will continue playing the default idle animation. Same instance when I want to go from crouch animation back to default. Bassicley the new set of animations do not “kick in” until the character moves, it will continue playing what was last playing.
I’m trying to see if maybe there’s a function in the animate script which I can call to force whatever happens when the character moves to update the animations.
I ended up adding a BindableEvent to the animate script and fired it everytime the configure function was called. Then from there it would initiate the onRunning function. It seems to work!! Thank you giving your time to help me.