Hey there! I’m making an admin bar based off Basic Admin. I’ve ran into an issue though. The event doesn’t fire even with the correct command. Any help would be greatly appreciated.
Problem snippet:
local function onGuiInputEntered(input)
if input and typeof(input) == "userdata" and input.UserInputType == Enum.UserInputType.Keyboard and input.KeyCode == Enum.KeyCode.Return then
if frame.Text == "uniform" then
-- Fire the remote event if the player typed "/uniform"
frame.Text = "TEST"
uniformEvent:FireServer(player)
end
-- Clear the text in the GUI and hide it
frame.Text = ""
tweenGuiFrame(initialSize)
isGuiVisible = false
print("command bar closed")
end
end
FULL
-- We must get the UserInputService before we can use it
local UserInputService = game:GetService("UserInputService")
-- Define the GUI frame and its initial and final sizes
local frame = script.Parent.TextBox
local initialSize = UDim2.new(1, 0, 0, 0)
local finalSize = UDim2.new(1, 0, 0.1, 0)
local player = game.Players.LocalPlayer
-- Define the duration, easing style, and easing direction of the tween
local tweenDuration = 0.09
local easingStyle = Enum.EasingStyle.Sine
local easingDirection = Enum.EasingDirection.In
-- Define the TweenInfo object that will be used by the TweenService
local tweenInfo = TweenInfo.new(tweenDuration, easingStyle, easingDirection)
-- Define a variable to keep track of whether the GUI is currently visible
local isGuiVisible = false
-- Define the remote event to fire when the player types "/uniform"
local uniformEvent = game.ReplicatedStorage.RemoteEvent
-- A function to tween the GUI frame to the specified size
local function tweenGuiFrame(size)
local propertiesToTween = {
Size = size
}
local tween = game:GetService("TweenService"):Create(frame, tweenInfo, propertiesToTween)
tween:Play()
end
local function onGuiInputEntered(input)
if input and typeof(input) == "userdata" and input.UserInputType == Enum.UserInputType.Keyboard and input.KeyCode == Enum.KeyCode.Return then
if frame.Text == "uniform" then
-- Fire the remote event if the player typed "/uniform"
frame.Text = "TEST"
uniformEvent:FireServer(player)
end
-- Clear the text in the GUI and hide it
frame.Text = ""
tweenGuiFrame(initialSize)
isGuiVisible = false
print("command bar closed")
end
end
-- A function to handle player input outside the GUI
local function onInputBegan(input, gameProcessed)
if input.KeyCode == Enum.KeyCode.Quote then
if isGuiVisible then
-- If the GUI is currently visible, tween it to its initial size and hide it
tweenGuiFrame(initialSize)
frame.Text = ""
isGuiVisible = false
print("command bar closed")
else
-- If the GUI is currently hidden, tween it to its final size and show it
tweenGuiFrame(finalSize)
isGuiVisible = true
frame.Text = "Enter a command."
print("command bar opened")
end
end
end
-- Connect the onGuiInputEntered function to the InputBegan event of the GUI
frame.FocusLost:Connect(onGuiInputEntered)
-- Connect the onInputBegan function to the InputBegan event of the UserInputService
UserInputService.InputBegan:Connect(onInputBegan)
Any help would be great, as my scripting skills are pretty lack luster.