Im trying to make a simple mana system where mana goes down when a key is pressed. (It's key press because all of the moves a key presses) But mine doesn't work with key presses so whats the fastest way to do that? If you need to see my script tell me.
✓ ANSWER ACCEPTED
What would be the best way to make a mana bar?
1 answer
✓ Accepted answer
Might need to see the script. Try using a keydown event that sets a value letting the script know it's still pressed and adding a loop that checks that value and does the code until the key is released. Example:
local Player = game.Players.LocalPlayer
local keypressed = false
local mouse = Player:GetMouse()
local mana = 10000
function keypress()
mana = mana-1
wait(0.1)
if keypressed then
keypress()
end
end
mouse.KeyDown:connect(function(key)
if key == "q" then
keypressed = true
keypress()
end
end)
mouse.KeyUp:connect(function(key)
if key == "q" then
keypressed = false
end
end)
This discussion is preserved as it was. New answers, comments, and votes are closed.
