Need help on remaking fnf music gui

You can write your topic however you want, but you need to answer these questions:

  1. What do you want to achieve? Keep it simple and clear!
    im trying to achieve fnf music gui (simple version) but i need help
  2. What is the issue? Include screenshots / videos if possible!
    the issue is that the order or position is wrong like
    image
    ^^^^^^^
    you can see that the last print was text4 but if you look at the gui

    ^^^
    the position of the frame is at the “TEST” button position
  3. What solutions have you tried so far? Did you look for solutions on the Developer Hub?
    nope, nobody
local us = game:GetService("UserInputService")
local tw = game:GetService("TweenService")

local currentIndex = 1
script.Parent.Buttons.Position = UDim2.new(0.145, 0,0.3, 0)

local function move()
	local c = script.Parent.Buttons:FindFirstChild(currentIndex)
	if c then
		local target = c.Position - UDim2.new(0,0,0.1,0)

		local tw = TweenInfo.new(0.5)  
		local g = {}
		g.Position = target
         print(c.Text)
		local tween = tw:Create(script.Parent.Buttons, tw, g)
		tween:Play()
	end
end

local function onKeyPress(input)
	if input.KeyCode == Enum.KeyCode.Down or input.KeyCode == Enum.KeyCode.H then
		currentIndex = currentIndex - 1
		if currentIndex == 0 then
			currentIndex = #script.Parent.Buttons:GetChildren() -- Move to the latest lol
		end
		move()
	elseif input.KeyCode == Enum.KeyCode.Up or input.KeyCode == Enum.KeyCode.G then
		currentIndex = currentIndex % #script.Parent.Buttons:GetChildren() + 1
		move()
	end
end

us.InputBegan:Connect(onKeyPress)

^^ heres the code of the padding
if also needed heres the code of generation

 local buttonTexts = {"Bopeebo", "Text2", "Text3", "Text4"} 

local lastpos = script.TextButton.Position

for i = 1,4 do
	local button = script:WaitForChild("TextButton"):Clone()
	button.Parent = script.Parent.Buttons
	button.Position = lastpos + UDim2.new(0.005, 0, 0.06, 0)
	lastpos = button.Position
	button.Name = i
	button.Text = buttonTexts[i] or "Unknown"
	wait()
end

script.Enabled = false

Note:
i also noticed that the order is also wrong in the frame but i deleted and enabled the regen, it still doenst work

2 Likes

has anyone ever seen this?? im still needing help!!!

i still need help :sob:!!!
this is important for me111!!1

Put the keycodes in a table and then search for the index of the keycode pressed

Then send that keycode to the move function and use it instead of currentIndex

Switch the order of the keycodes around in the table if its wrong


local function move(foundIndex)
	local c = script.Parent.Buttons:FindFirstChild(foundIndex)
	if c then
		local target = c.Position - UDim2.new(0,0,0.1,0)

		local tw = TweenInfo.new(0.5)  
		local g = {}
		g.Position = target
         print(c.Text)
		local tween = tw:Create(script.Parent.Buttons, tw, g)
		tween:Play()
	end
end

local keyCodes = {Enum.KeyCode.Down, Enum.KeyCode.H, Enum.KeyCode.Up, Enum.KeyCode.G}

local function onKeyPress(input)

  local foundIndex
  for index, keyCode in ipairs(keyCodes) do -- use ipairs for ordered loop

    if keyCode ~= input.KeyCode then continue end -- skip if its the wrong keycode
    foundIndex = index

  end

  move(foundIndex)
end
local tw1 = game.TweenService
local currentb = nil
local function move(foundIndex)
	local c = script.Parent:FindFirstChild(foundIndex)
	if c then
		local target = c.Position - UDim2.new(0,0,0.1,0)
currentb = c
		local tw = TweenInfo.new(0.5)  
		local g = {}
		g.Position = target
		print(c.Text)
		local tween = tw1:Create(script.Parent, tw, g)
		tween:Play()
		wait()
		print(currentb.Text)
	end
end

local keyCodes = {Enum.KeyCode.Down, Enum.KeyCode.H, Enum.KeyCode.Up, Enum.KeyCode.G}

local function onKeyPress(input)

	local foundIndex
	for index, keyCode in ipairs(keyCodes) do -- use ipairs for ordered loop

		if keyCode ~= input.KeyCode then continue end -- skip if its the wrong keycode
		current = current ~= 4 and current + 1 or 1

	end

	move(current)
end
game.UserInputService.InputBegan:Connect(onKeyPress)
move(current)

same thing but reverted order (also the buttons are a number now (1 to 4)

i do think i will quit this code because it sucks and also its hard to fix
if anyone never replies to this with the fixen version i might give an solved mark
althought i will not mark solution