Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

How Do I Play A Function At A Required Time?

Asked by 5 years ago

I have a crawling animation that i want to run when humainoid health = 1 and then to stop playing once health reaches back to 101 hp anybody able to explain? *I'm not asking for a script a detailed explanation and example will do just fine, Thanks *

0
You would want to use "HealthChanged" then check for the current health after every health change using an if statement. If the health is equal to 1 or 101 then you would do as you need. https://developer.roblox.com/api-reference/event/Humanoid/HealthChanged Avi_i 2 — 5y

2 answers

Log in to vote
0
Answered by 5 years ago
Edited 5 years ago

Use a function which is basically an event that starts the whole script. The specific one you're looking for is called HealthChanged. Click here for a detailed tutorial to help you write your script.

0
A function is not an "event that starts the whole script", it is a container of reusable code. User#24403 69 — 5y
Ad
Log in to vote
0
Answered by 5 years ago
Edited 5 years ago

This is small script (It may doesn't work but can show you how it need look like.) Of course if u want auto-healing in game.

repeat
 if humanoid.Health = 1 then
  wait(10/5/2/3/100500)
  humanoid.Health = humanoid.Health + 1
until humanoid.Health = 101

But if you don't like to have auto-healing. Use this

local randomvariable = 0

if humanoid.Health = 1 then
 randomvariable = 1
 startyouranimationhere
end
if humanoid.Health = 101 then
 if randomvariable = 1 then
  stopyouranimation
end
0
Ya u can just use function instead coupleofstrokes. :\ Fefefefe234 0 — 5y

Answer this question