How can I make a timer during which the player have to press two buttons?

  1. What do you want to achieve? I want to achieve a timer (the timer counts down from 3 seconds to 0, the timer doesn’t really need any GUI’s, it can’t even be visible to player) system, until the timer runs out, the player must press two buttons (S and W), if the player has time to press them before the timer ends - debouce occurs, if not in time - the script continues.

  2. What is the issue? My stupidness.

  3. What solutions have you tried so far? … none honestly.

An 3D Button or An 2D one? what one

Nono, like, a keyboard button .

You may need to use Input Service

local UIS = game:GetService("UserInputService")
local plr = game.Players.LocalPlayer
local Mouse = plr:GetMouse()
local Debounce = false
local timer = script.timer.Value

timer.Value = 100 (example)

repeat timer.Value += 1

UIS.InputBegan:Connect(function(Input)
	if Input.KeyCode == Enum.KeyCode.S and Input.KeyCode == Enum.KeyCode.W and Debounce == false and timer.Value = <= 0 then
             print("Pressed V And W")
   
        end
end)

Thank you!! I was almost desperate really, I will figure out the rest myself, at least i understand the basis now

1 Like

Its ok, i will improve that code later, bc i am on online class

1 Like

u made a mistake here it suppose to be
Enum KeyCode.W not Enu.KeyCode.W

1 Like

Yeahh, thanks for reminding me

1 Like

Sorry, script error says: Expected (“Until” to close “Repeat” at line 9), got eof; did you forgot to close “=” at line 12? and in the output it says: ServerScriptService.Script:12: Expected ‘then’ when parsing if statement, got ‘=’. What should I do?

Where it says

repeat timer.Value += 1

You need to add an until after that

repeat timer.Value += 1 until

Now the output says: ServerScriptService.Script:12: Expected ‘then’ when parsing if statement, got ‘=’, and the error says: Expected identifier when parsing expression, got ‘then’