#Low hp animations

1 messages · Page 1 of 1 (latest)

nocturne falcon
#

So I made 2 low hp animations: Running and idle but for some reason the running one is always playing, if hp goes back to more than 33% it stops tho, but the idle one is not working, I'll send the script if anyone can tell me wich part I should correct about it

local character = script.Parent
local humanoid = character:FindFirstChild("Humanoid")
local RunanimationId= "108538814490004"
local IdleanimationId= "127159591344032"
local loadedIdleAnimation = humanoid:LoadAnimation(IdleanimationId)
local loadedRunAnimatin = humanoid:LoadAnimation(RunanimationId)

while wait do
if humanoid.Health <= 33 then do
if Enum.HumanoidStateType.Idle then do
loadedRunAnimatin:Stop()
wait(0.5)
loadedIdleAnimation:Play()
loadedIdleAnimation.looped = true
end
if Enum.HumanoidStateType.Walking then do
loadedIdleAnimation:Stop()
wait(0.5)
loadedRunAnimatin:Play()
loadedRunAnimatin.looped = true
end

else do
        end 
    end
end  
    loadedIdleAnimation:Stop()
    loadedRunAnimatin:Stop()
    end
end 

end

keen pivot
#

This script is interesting, to say the least. First of all, you don't need to have "do" after the if then statements. Second, you aren't checking the humanoids state properly, and instead just checking if an enum object exists.

if Enum.HumanoidStateType.Idle then do

should be changed to this for example:

if humanoid:GetState() == Enum.HumanoidStateType.Idle then
opal vessel
#

check humanoid.MoveDirection.Magnitude instead of Enum.HumanoidStateType for idle (0) or walking (>0) in the while loop play idle animation when stationary and run animation when moving, only if health <33%. Stop both animations when health >33%

#

idk i might have said something ass

#

W

keen pivot
#

Also, get rid of the "else do end," it's redundant

#

In fact, I don't mean to be rude when I say this, but please look up a youtube tutorial on how loops and if statements work so my eyes don't need to see such horrors again

#

The fact this even runs without erroring is a miracle in of itself

opal vessel
#

give this man a round of applause

keen pivot
#

It's kind of impressive

opal vessel
#

weve all been in that state he is 😭

keen pivot
opal vessel
#

ok what the fuck

naive silo
keen pivot
#

Clearly he has some idea what he's doing, since he got animations running, but if he knows how to do that then how did it end up like this

naive silo
#

i'd say ai, but ai doesnt make mistakes like that with the if statements

#

also the while wait do is interesting

opal vessel
#

waiting for absolute nothing

naive silo
#

its not actually waiting

#

its just infinite loop; while true do

opal vessel
#

i kno

keen pivot
naive silo
#

if Enum.etc then... are also always true

opal vessel
#

i just said somethig bed

naive silo
#

so its constantly switching back and forth between both animations every 0.5 seconds coz the conditions are wrong lol

#

if the conditions were correct it would crash studio and roblox player under some circumstances coz theres no waits in the loop

#

e.g jump at low health = crash

keen pivot
#

This script is truly something

naive silo
#

indeed it is

keen pivot
#

I honestly cannot comprehend how or why he even ended up doing it like this

naive silo
#

it should be studied to understand how much rot must be in someones brain to write like this

opal vessel
#

drunk scripting

#

😭

naive silo
keen pivot
#

This is just mind boggling

keen pivot
opal vessel
#

fentanyl

keen pivot
#

The fact that the formatted code somehow manages to form a near perfect semi-circle with just 24 lines still bewilders me

nocturne falcon
jagged helmBOT
#

studio** You are now Level 1! **studio

nocturne falcon