I am making a game where in a computer in the game I click a button it would open a frame where I enter a username then press enter to take me to an another frame where I type out a message then press press submit to enter it in a queue where and claim the note to deliver it to the rightfull peron (whatever person typed in the first frame) and if there is no username have it deliverd to an npc. my problem is the enter button to take me from frame one to frame two dont work
local NextButton = script.Parent
local ScreenGui = NextButton.Parent
local UsernameTextBox = ScreenGui.Frame.UsernameTextBox
-- List of NPC names
local npcNames = {"ROBLOX", "Bacon", "builderman"}
-- Assuming you have a RemoteEvent for sending messages to NPCs
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local RemoteEvent = ReplicatedStorage:WaitForChild("RemoteEvent")
UsernameTextBox.InputBegan:Connect(function(input)
if input.UserInputType == Enum.UserInputType.Keyboard and input.KeyCode == Enum.KeyCode.Return then
local username = UsernameTextBox.Text
if username == "" then
-- If username is empty, randomly select an NPC
local randomIndex = math.random(1, #npcNames)
local randomNPC = npcNames[randomIndex]
print("Randomly selected NPC:", randomNPC)
-- Now you can use 'randomNPC' as the recipientUsername or do further processing
-- Example: Send a message to the randomly selected NPC
local message = ScreenGui.Frame.MessageTextBox.Text .. randomNPC
RemoteEvent:FireServer("SendMessageToNPC", message, randomNPC)
else
print("Enter key pressed")
NextButton.MouseButton1Click:Fire()
end
end
end)
hierarchy
I expected it to take me to the second frame to type the message.
Andrew N is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.