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

(Answered) How do I get rid of slash in custom chat's chat bar?

Asked by 4 years ago
Edited 3 years ago

I open my custom chat's chat bar and whatever I type starts with "/". How do I stop the slash from proceeding everything I type so I may go straight to typing into the chat rather than have to backspace the slash out?

local chatInput = script.Parent:WaitForChild("ChatInput")
local uis = game:GetService("UserInputService")
local onChatInputted = game.ReplicatedStorage:WaitForChild("OnChatInputted")
local cooldown = 1
local isCoolingDown = false

uis.InputBegan:Connect(function(key, gameProcessed)     
    if key.KeyCode == Enum.KeyCode.Slash and not gameProcessed then         
        chatInput:CaptureFocus()        
    end
end)

chatInput.FocusLost:Connect(function(enterPressed)
    if not enterPressed then return end 
    local input = chatInput.Text    
    chatInput.Text = "" 

    if string.len(input) > 0 then       
        if isCoolingDown == true then           
            chatInput.Text = "Wait for cooldown to end!"            
            return      
        end     
        isCoolingDown = true        
        onChatInputted:FireServer(input)        
        wait(cooldown)          
        isCoolingDown = false   
    end 
end)

1 answer

Log in to vote
0
Answered by 4 years ago

Add a wait(0.1) between lines 08 and 09 :)

Ad

Answer this question