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

How would i find if someone is in the air or on the ground?

Asked by 9 years ago

I made a script to make a shockwave when the boss lands after jumping. The thing is, how would I tell if he's back on the ground? (No OnTouched the boss will be on multiple bricks and I don't want to much lag)

1 answer

Log in to vote
0
Answered by 9 years ago

Well, if you have parts on your boss, then you can use Position and an if statement. For example,

01OnGround = false -- Assuming the boss starts on the ground
02BossTorso = workspace.(Boss model).(Boss's chest)
03--Replace those with the bosses chest, and where it says (Boss model) is what the boss's torso is stored under. If it's not workspace, change it to the location of the boss
04DesiredHeight = --(Whatever the grounds y is to find it, click on the ground and look under "Position" and "Y") --This is where he has to be to be "on the ground"
05BossHeight = --(You can experiment here but I'd probably recommend 7, or so depending on how tall your boss is) --This is subtracted from the value because you're measuring the torso
06while 1==1 do --Repeats 4ever
07if BossTorso.Position.y <= DesiredHeight + BossHeight then --Checks if the bosses torso 5 studs away from the ground
08    OnGround = true
09    break--breaks loop remove this if you want it to go on forever.
10    end
11wait(1)
12end

I told you want to replace in the comments of the script, try using that reply if that doesn't make sense. Use OnGround in a loop, to see if he hits the ground, for example,

1while 2==2 do
2if OnGround = true
3        --Do whatever you're shockwave thing is
4    end
5wait(1)
6end

If I were to have a brick in workspace, called "Torso", then this script will work for it.

01OnGround = false
02BossTorso = workspace.Torso
03DesiredHeight = -10
04BossHeight = 3
05while 1==1 do
06if BossTorso.Position.y <= DesiredHeight + BossHeight then
07    OnGround = true
08    break
09    end
10wait(1)
11end
12while 1==1 do
13    if OnGround==true then
14        print("Yo")
15        break
16    end
17    wait(1)
18end

Assuming that your baseplate is really thin, if it's thick, change the BossHeight to something like 10 or 20. This prints "Yo" Whenever it touches the ground.

0
EDITED DO NOT USE THE OLD ONE, WILL CRASH YOUR GAME feeliirie 5 — 9y
0
Another edit, added working code, finally XD feeliirie 5 — 9y
Ad

Answer this question