You can write your topic however you want, but you need to answer these questions:
-
What do you want to achieve? Keep it simple and clear!
I want my username GUI to go to the next frame when you click enter if the player username right that on the server
-
What is the issue? Include screenshots / videos if possible!
I’m trying to make a username GUI that goes to the next frame when you click the enter button but when I click enter it doesn’t do anything when you click the button in this is a script I’m using that from another project I was working on at the other place that had the same functionality in it works fine from there but its not working on my gui on my place I’m on now heres my GUI script
local gui = script.Parent
local frames = {gui.OrderFrame}
local username = gui.NameFrame.ImageLable.TextBox
local textbutton = gui.NameFrame.ImageLable.enter
username.ClearTextOnFocus = false
username.PlaceholderText = "Enter player name"
username.FocusLost:Connect(function()
local playername = username.Text
end)
textbutton.MouseButton1Click:Connect(function()
local playerName = username.Text
-- Check if the entered player name exists
local player = game.Players:FindFirstChild(playerName)
if player then
local currentIndex = table.find(frames, gui.OrderFrame)
local nextIndex = (currentIndex % #frames) + 1
local nextFrame = frames[nextIndex]
-- Make the next frame visible before the tween animation
nextFrame.Visible = true
-- Tween the position of the order frame
gui.OrderFrame:TweenPosition(nextFrame.Position, Enum.EasingDirection.In, Enum.EasingStyle.Quad, 0.5, true, function()
nextFrame.Visible = true
gui.NameFrame.Visible = false
gui.NameFrame.ImageLable.enter.Visible = false
gui.NameFrame.ImageLable.TextBox.Visible = false
end)
else
warn("Player not found! Please enter a valid player name.")
end
end)
1 Like
on the CurrentIndex check if its actually finding the frame first
ok I did that in it is still not working here the updated script with that check in it
local gui = script.Parent
local frames = {gui.OrderFrame}
local username = gui.NameFrame.ImageLable.TextBox
local textbutton = gui.NameFrame.ImageLable.enter
username.ClearTextOnFocus = false
username.PlaceholderText = "Enter player name"
username.FocusLost:Connect(function()
local playername = username.Text
end)
textbutton.MouseButton1Click:Connect(function()
local playerName = username.Text
-- Check if the entered player name exists
local player = game.Players:FindFirstChild(playerName)
if player then
-- Find the current index of the frame
local currentIndex = table.find(frames, gui.OrderFrame)
if not currentIndex then
warn("OrderFrame not found in frames table! Please check your frames list.")
return
end
local nextIndex = (currentIndex % #frames) + 1
local nextFrame = frames[nextIndex]
-- Make the next frame visible before the tween animation
nextFrame.Visible = true
-- Tween the position of the order frame
gui.OrderFrame:TweenPosition(nextFrame.Position, Enum.EasingDirection.In, Enum.EasingStyle.Quad, 0.5, true, function()
nextFrame.Visible = true
gui.NameFrame.Visible = false
gui.NameFrame.ImageLable.enter.Visible = false
gui.NameFrame.ImageLable.TextBox.Visible = false
end)
else
warn("Player not found! Please enter a valid player name.")
end
end)
what does next index and next frame print out
it prints nothing also it does prints out Player not found! Please enter a valid player name. when I do enter the right player name
Okay i think i found why currentIndex isnt working
Table.find fails to find that index because it requires a value (string, number) ect and your trying to look for a username in a table im guessing and this is how the table is appearing:
local HowYourTableAppears = {
{
Frame
}
}
local HowItShouldBe = {
["Username"] = Frame
}
I may be wrong though
1 Like