How would I make a hold keybind thing?

What I am trying to do here/achieve here is the thing it fortnite kinda, the player drinks a mini shield and it has like the little countdown bit, however I want it to be the same thing but lets say I have a textlabel that says “E” to hold the E key.

I want like a little outline/bar/progress bar that goes round it and if the players stops holding the E key then I want it to slowly deplete.
How would I do that? I tried searching it up but I saw “Keybind door” :joy:

I know I can use the KeyHold thing but I don’t know how that could be used in this situation.

5 Likes

The ContextActionService may help on this. You should take it a look. Anyway, here’s some kinda example code.

Also, this from the UserInputService:

--[[ Varaibles ]]--
local uis=game:GetService("UserInputService");

--[[ Main ]]--

-- pressing
uis.InputBegan:connect(function(input)
    if input.KeyCode==Enum.KeyCode.E then
        print("pressing the key E");
        -- your code here
    end
end)

-- left 
uis.InputEnded:connect(function(input)
    if input.KeyCode==Enum.KeyCode.E then
        print("you have stopped");
        -- your code 
    end
end)

If you find any error, let me know. I’m gonna try to update the script as soon as possible. For the GUI decreasing and increasing, you should have a number value and from there and on just tween the GUI.

Have a nice day! - @Lil_SharkyBoy

3 Likes

That is very helpful, thanks.

I will just be using this right now… Any tips on how I would make the tween bit work and the outline/circle bit?

I made the button/keyboard key which was really easy.

key

1 Like

As I already said you should have a NumberValue for this. When the player is drinking the shiel potion just go and increase the value. With the NumberValue increasing Tween the GUI (you can make calculations of how the GUI can actually tween because you’ll need to divide or multiply some Vectors of the GUI).

Anyway, isn’t that difficult and you could just go and search on Youtube “How to make a Stamina Bar” or a “Tweening GUI from a value”.

I hope this helps you.

4 Likes

If we could apply soulutions on more than 1 post then I would mark both of them :slight_smile:

I could make a square progress bar instead or use the grey background/shadow as the progress bar and the white “E” text with increasing TweenSize (if you know what I mean).

5 Likes

Hey! I have just read a little discusion of what plugin would better. So… I got one that is the best so far! This one have a lot of features instead of only roundify.

https://www.roblox.com/library/4474084133/uiDesign-Plus

For both of you and maybe this is off-topic. But I would like to share this awesome plugin with you.

Pings: @real_SkeletonBloxYT and @MrOofBoyPlayz

2 Likes

I know, I already have that. Just haven’t used most of the features or even looked at them. Well I don’t have plus I have lite.

1 Like

you can also do it with the plr.getmouse function inside a Localscript

1 Like