Why doesnt this work?

  1. What do you want to achieve? Keep it simple and clear!

a console that when you press enter it sends the text to the server and removes the text

  1. What is the issue? Include screenshots / videos if possible!

The stuff inside the if statement doesnt ever run

  1. What solutions have you tried so far? Did you look for solutions on the Developer Hub?

didnt find anything like this specifically

this is what i currently have, yes its a local script and is in the textbox.

local isFocused = false

script.Parent.Focused:Connect(function()
	isFocused = true;
end)

script.Parent.FocusLost:Connect(function()
	isFocused = false;
end)

game:GetService("UserInputService").InputBegan:Connect(function(input)
	if input.KeyCode == Enum.KeyCode.Return and isFocused then
		game:GetService("ReplicatedStorage"):WaitForChild("Remotes"):WaitForChild("PrivateServer"):WaitForChild("submitCommand"):FireServer(script.Parent.Text)
		script.Parent.Text = ""
	end
end)
1 Like

local function onTextBoxFocusLost(enterPressed, inputObject)
	if enterPressed then
		game:GetService("ReplicatedStorage"):WaitForChild("Remotes"):WaitForChild("PrivateServer"):WaitForChild("submitCommand"):FireServer(script.Parent.Text)
		script.Parent.Text = ""
	end
end

script.Parent.FocusLost:Connect(onTextBoxFocusLost)

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.