So I’ve made this script that once the game start you must click every frame in order, but it doesn’t seem to work it worked perfectly fine at the start but I can’t get it to how it worked. any help?
local frameOrder = { "TextButton1", "TextButton2", "TextButton3" }
local currentIndex = 1
local player = game.Players.LocalPlayer
local mouse = player:GetMouse()
local n1 = script.Parent.TextButton1
local n2 = script.Parent.TextButton2
local n3 = script.Parent.TextButton3
local newX = math.random(1, 9) / 10
local newY = math.random(1, 9) / 10
script.Parent.Ready.MouseButton1Click:Connect(function()
-- wait(4)
print("run")
n1.Visible = true
n2.Visible = true
n3.Visible = true
n1.Position = UDim2.new(newX, 0, newY, 0)
n2.Position = UDim2.new(newX, 0, newY, 0)
n3.Position = UDim2.new(newX, 0, newY, 0)
local function onClick(button)
if button.Name == frameOrder[currentIndex] then
button.Visible = false
currentIndex = currentIndex + 1
if currentIndex > #frameOrder then
print("Complete")
end
end
end
for _, buttonName in ipairs(frameOrder) do
local button = script.Parent:FindFirstChild(buttonName)
if button then
button.MouseButton1Click:Connect(function()
onClick(button)
end)
end
end
end)
local function randomizeXY(button)
local xy = math.random(1, 9) / 10
button.Position = UDim2.new(xy, 0, xy, 0)
end
-- This goes inside the "MouseButton1Click" function
randomizeXY(n1)
randomizeXY(n2)
randomizeXY(n3)