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

How do I have the same key do one thing if pressed once, but another thing if pressed twice?

Asked by 5 years ago

I'm trying to create a game where if a player presses F, an orb appears over their shoulder, and if they press it again, a second orb appears in a second place, the code is essentially this (this is shortened down):

player = game.Players.LocalPlayer mana = 2 numberoforb = 0

function onKeyPress(input, gameProcessedEvent) if input.KeyCode == Enum.KeyCode.F and mana > 0 and numberoforb == 0 then

[It makes the orb] mana = mana-1 numberoforb = numberoforb + 1

end

elseif input.KeyCode == Enum.KeyCode.F and bang >0 and numberofbang == 1 then [it makes the second orb] end end end

for some reason, this only lets me spawn 1 orb, if you press F again, it does nothing. What am I doing wrong?

1 answer

Log in to vote
0
Answered by 5 years ago

The "numberofbang" variable are not defined, I think you wanted to put numberoforb

0
Yeah, I changed bang and numberofbang to orb and numberoforb to make it make more sense, but I guess I missed those two. TheNewDalek 0 — 5y
Ad

Answer this question