This animation plays but in the next part of the script it never stops.
It somewhat works now, but It starts “T-Posing” meaning that the juggling animation doesn’t start instantly even though the Juggling variable is set to true.
I have also removed those occasional “Spasms” to the teddy bear for the moment because they seemed to bug out everything, also the reason for the while loop was that the “idle” animation isn’t looped, because I needed to insert those random “Spasms” (Also known as “Restless”) randomly, so the current code is:
Juggling = true
local hum = script.Parent:WaitForChild("Humanoid")
local a = hum:WaitForChild("Animator"):LoadAnimation(script.Idle)
local b = hum:WaitForChild("Animator"):LoadAnimation(script.Restless1)
local c = hum:WaitForChild("Animator"):LoadAnimation(script.Restless2)
local d = hum:WaitForChild("Animator"):LoadAnimation(script.Restless3)
local e = hum:WaitForChild("Animator"):LoadAnimation(script.Juggling1)
local GenValue = script.GeneratorOn
local function AnimationHandler()
if Juggling == true then
a:Stop()
e:Play()
else
--
e:Stop()
a:Play()
end
end
GenValue.Changed:Connect(function(NewValue)
if NewValue then
Juggling = true
print("Juggling is true")
else
Juggling = false
print("Juggling is false")
end
AnimationHandler()
end)
And here’s the video
Video
The Juggling starts as true
so you can call the animation to start animation this model, it would look like:
Juggling = true
local hum = script.Parent:WaitForChild("Humanoid")
local a = hum:WaitForChild("Animator"):LoadAnimation(script.Idle)
local b = hum:WaitForChild("Animator"):LoadAnimation(script.Restless1)
local c = hum:WaitForChild("Animator"):LoadAnimation(script.Restless2)
local d = hum:WaitForChild("Animator"):LoadAnimation(script.Restless3)
local e = hum:WaitForChild("Animator"):LoadAnimation(script.Juggling1)
local GenValue = script.GeneratorOn
local function AnimationHandler()
if Juggling == true then
a:Stop()
e:Play()
else
--
e:Stop()
a:Play()
end
end
AnimationHandler()
GenValue.Changed:Connect(function(NewValue)
if NewValue then
Juggling = true
print("Juggling is true")
else
Juggling = false
print("Juggling is false")
end
AnimationHandler()
end)
this will probably start the game with the model animating
It does! I’m not sure why though, isn’t the function supposed to run as soon as it shows up? like what’s the point of calling it and why does it work?
Here we create the function but the function will only run the code once you call it, after creating the function we call it, so as the Juggling variable is true already, it plays the animation
Thanks for the concise explanation