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

How to "stall" code until a certain key is pressed a second time?

Asked by 9 years ago

I'm making my own chat system and noticed that now, ROBLOX removes their '/' to type along with everything thing else. So, I need to make my textbox function and I'm using the Input service and checking for / so the play may begin typing, However, I do not know how to stop the player from typing to the textbox if they press / a second time. Here is what I tried, but it will fire if the player presses anything else after pressing /:

LocalScript

UserInput = game:GetService("UserInputService")
Plr = game.Players.LocalPlayer
Typing = false

UserInput.TextBoxFocused:connect(function()
    Typing = true
    UserInput.TextBoxFocusReleased:wait()
    Typing = false
end)

UserInput.InputBegan:connect(function(Pressed)
    if Typing == false then
        if Pressed.KeyCode == Enum.KeyCode.Slash then
            print("Started to type")
            UserInput.InputBegan:wait()
            print("Decided to end typing")
        end
    end
end)

If there is a Tutorial on wiki about things like this, a link would help too

Answer this question