How do I make it so something only works when you are holding down button?
I would use UserInputService
.
local uis = game:GetService("UserInputService") local active = false uis.InputBegan:Connect(function(input) -- first parameter is the InputObject if input.KeyCode == Enum.KeyCode.Q then-- Change "Q" to whatever key you'd like to. active = true repeat -- repeats until it's false wait(1) -- make sure there is a wait or else it will crash your studio print('a') until active == false end end) uis.InputEnded:Connect(function(input) if input.KeyCode == Enum.KeyCode.Q then active = false -- sets it to false when button is released end end) end