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

What would be the best way to make a mana bar?

Asked by 9 years ago

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.

1 answer

Log in to vote
0
Answered by 9 years ago

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)
Ad

Answer this question