Wait For Time Key

You can write your topic however you want, but you need to answer these questions:

  1. What do you want to achieve? Keep it simple and clear!

a rope on the hand that can be large or short

  1. What is the issue? Include screenshots / videos if possible!

i wan’t make when you press a key on 0.5 seconds then automatically be short or large
but when i press on a time shorter of 0.5 activates the auto short or large

  1. What solutions have you tried so far? Did you look for solutions on the Developer Hub?

yes

After that, you should include more details if you have any. Try to make your topic as descriptive as possible, so that it’s easier for people to help you!

if wait(0.5) then
-- plays the code for auto large or short
end

Please do not ask people to write entire scripts or design entire systems for you. If you can’t answer the three questions above, you should probably pick a different category.

You should try making a debounce boolean so when you press a key, it would become true and then false after .5 seconds

local debouce = false

-- key press event
if not debounce then -- on 0.5 seconds
	debounce = true
	-- code
	wait(0.5)
	debounce = false
	
else -- shorter than 0.5 seconds
	-- code
end

I hope this helps!

1 Like

that works width the two keys?

It will if you use UserInputService.InputBegan or other events that fire from all keyboard keys.

1 Like

much much much much much thanks :slight_smile:

1 Like

I made something like this for someone yesterday.

local UIS = game:GetService("UserInputService")

UIS.InputBegan:Connect(function(input, processed)
	if input.KeyCode == Enum.KeyCode.A then --checks if the "A" key is pressed
		local count = 1
		while wait() do --every 1/60th of a second
			if UIS:IsKeyDown(Enum.KeyCode.A) then
				count +=1
			else
				break --break out of while loop
			end
		end
		if count <= 30 then --key held for 0.5 seconds or less
			--some action
		else --key held for more than 0.5 seconds
			--do some other action
		end
	end
end)