Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

How can I make it so that the repeat stops after C has stopped being held?

I've tried by having the repeat loop stop when the C input has ended or when its done being held

local UIS = game:GetService(UserInputService)

UIS.InputBegan:Connect(function(input, gameProcessed) if(not gameProcessed) then if(input.KeyCode == Enum.KeyCode.C) then repeat wait(0.3) print('pansy potato') until UIS.InputEnded == true end end end)

Any help would be appreciated ^^ Thanks!

1 answer

You can try using this:

It will keep printing out 'Pansy Potato' as you're holding down the 'C' key and whenever you release the 'C' key it will stop printing.

Also make sure to format your code next time so it's easier for us to read the code you have provided.

local UIS = game:GetService("UserInputService")
local Loop = false

UIS.InputBegan:Connect(function(Input, GameProcessed)
	
	if not (GameProcessed) then
		if (Input.KeyCode == Enum.KeyCode.C) then
			Loop = true
			repeat wait(0.3) print("Pansy Potato") until Loop == false
		end
	end
end)

UIS.InputEnded:Connect(function(Input, GameProcessed)
	
	if not (GameProcessed) then
		if (Input.KeyCode == Enum.KeyCode.C) then
			Loop = false
		end
	end
end)

Hope this helps.

This discussion is preserved as it was. New answers, comments, and votes are closed.