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

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

Asked by 3 years ago

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

Log in to vote
0
Answered by 3 years ago
Edited 3 years ago

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.

Ad

Answer this question