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

How can I make so you have to HOLD down E for something to trigger?

Asked by 1 year ago
Edited 1 year ago

So basically I am trying to make a custom proximity prompt, I want the player to see that theyre holding E down by having a bar stretch across (like a loading bar) and I don't want the player to only have to press it, and make it so if they let go of E before the 1 second time is up then they have to do it again.

So how do I make it so the player has no choice but to hold down E for 1 second in order to have the door open, and then while they are holding E down the "bar" stretches for until the 1 second is over (and it opens) or the player lets goes of e before (and nothing happens)

I dont want a prompt because i want the bar to open at the same time as im holding down E. A prompt would make the bar open after E


local bar = script.Parent.frontdoors.BillboardGui.Bar local prompt = script.Parent.frontdoors.ProximityPrompt2 local UserInputService = game:GetService("UserInputService") local KeyHeld = Enum.KeyCode.E local function isEKeyDown() return UserInputService:IsKeyDown(KeyHeld) end local function input(input,gameProcessedEvent) if not isEKeyDown() then bar.Transparency = 0 bar:TweenSize(UDim2.new(0, 0, 0, 3), "Out", "Sine", 1) wait(1.01) bar.Transparency = 1 bar:TweenSize(UDim2.new(0, 0, 0, 3), "Out", "Sine", 0) bar.Transparency = 0 wait() else bar.Transparency = 0 bar:TweenSize(UDim2.new(0, 50, 0, 3), "Out", "Sine", 1) wait(1.01) bar.Transparency = 1 bar:TweenSize(UDim2.new(0, 0, 0, 3), "Out", "Sine", 0) bar.Transparency = 0 wait() end end UserInputService.InputBegan:Connect(input)

Answer this question