Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

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

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

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

1 comment

0

Yeah, I changed bang and numberofbang to orb and numberoforb to make it make more sense, but I guess I missed those two.

This discussion is preserved as it was. New answers, comments, and votes are closed.