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

How would I make a GUI not open while typing?

Ok so I have a problem. I got a Webhook report gui and script which opens by pressing the M key. But when I press M while typing it opens the GUI. How can I solve this?

local key = Enum.KeyCode.M -- Change the key if you want.
local gui = script.Parent.main -- Main frame
local plr = game.Players.LocalPlayer -- get local player
local UIS = game:GetService("UserInputService") -- get service

gui:TweenPosition(UDim2.new(0.382, 0, 1.229, 0))

UIS.InputBegan:Connect(function(Input)
	if Input.UserInputType == Enum.UserInputType.Keyboard and Input.KeyCode == key then --User pressed key
		if gui.Position == UDim2.new(0.382, 0, 0.229, 0) then --If open
			gui:TweenPosition(UDim2.new(0.382, 0, 1.229, 0)) --Close UI
		else --Is closed
			gui:TweenPosition(UDim2.new(0.382, 0, 0.229, 0)) --Open UI

		end
	end
end)


local sendbtn = script.Parent.main.send --- send button
local message = script.Parent.main.messageinput -- message box
local repstorage = game:WaitForChild("ReplicatedStorage")
local send = repstorage.reportevents.send
local sendcheck = false -- stop spam of the send button
local cooldowntxt = script.Parent.main.cooldown
cooldowntxt.Visible = false
---- DISCORD WEBHOOK CONFIG IS IN SERVERSCRIPTSERVICE (report)

sendbtn.MouseButton1Click:Connect(function()
	if sendcheck == false then -- checks if it was sent recently
		sendcheck = true
		send:FireServer(message.Text, sendcheck) -- sends it to server from client (serverscriptservice)
		sendbtn.Text = "Sent!" -- Customize if you want
		wait(0.7)-- Customize if you want
		sendbtn.Text = "A staff member will be with you soon!"-- Customize if you want
		wait(1.5)-- Customize if you want
		sendbtn.Text = "Send"-- Customize if you want
		cooldowntxt.Visible = true
		wait(70)-- Customize if you want
		sendcheck = false
		cooldowntxt.Visible = false
	end
end)

print("Config loaded")

1 comment

0

There is a second parameter to UIS.InputBegan that checks if it's coming internally, known as gameProcessedEvent, check if it's false at the start. of line 9

1 answer

UIS.InputBegan:Connect(function(gameProcessedEvent)
if gameProcessedEvent then return end

end)

Since gameprocessedevent is confusing, I suggest you type isTyping instead

1 comment

0

The input is always before gameprocessed i think. UIS.InputBegan:Connect(function(keythattheypressed, gameProcessedEvent). Also doesn't matter what you name them.

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