Wired hover ball spawning with e2 help

Ok. im using this for my wired hover balls on a object im making.

if (Space) {Hover++} elseif (Alt) {Hover–} else {Hover}

but every time i respawn the save the hover balls always go to the 0 on the z axis. is there any way to make the E2 set the Hover output when i spawn the object to what ever the hight is at where im spawning it?


if (duped()) {Hover = entity():pos():z()}

Also, in your code, you can remove “else {Hover}”. It does nothing.

Edit:
Decided to optimize your code…


Hover += Space - Alt

This works like this:
If you don’t hold down any key at all, it will be
Hover += 0 - 0
So it won’t do anything at all.

If you hold down Space, it will be
Hover += 1 - 0
Which is the same as
Hover += 1
So it will add 1 to hover (Fly up).

If you dont down Alt, it will be
Hover += 0 - 1
Which is the same as
Hover += -1
Which in turn is the same as
Hover -= 1
So it will subtract 1 to hover (Fly down).

thanks for that.