-- Create a ScreenGui
local gui = Instance.new("ScreenGui")
gui.Parent = game.Players.LocalPlayer.PlayerGui
-- Create a Frame to hold the GUI elements
local mainFrame = Instance.new("Frame")
mainFrame.Size = UDim2.new(0, 150, 1, 0)
mainFrame.Position = UDim2.new(0, 0, 0, 0)
mainFrame.BackgroundColor3 = Color3.new(0.2, 0.2, 0.2)
mainFrame.BorderSizePixel = 0
mainFrame.Parent = gui
-- Create a ScrollingFrame
local scrollingFrame = Instance.new("ScrollingFrame")
scrollingFrame.Size = UDim2.new(1, 0, 1, 0)
scrollingFrame.Position = UDim2.new(0, 0, 0, 0)
scrollingFrame.Parent = mainFrame
-- Function to handle button click
local function buttonClick(buttonNumber)
if buttonNumber == 1 then
print("Button 1 clicked!")
elseif buttonNumber == 2 then
print("Button 2 clicked!")
elseif buttonNumber == 3 then
print("Button 3 clicked!")
elseif buttonNumber == 4 then
print("Button 4 clicked!")
elseif buttonNumber == 5 then
print("Button 5 clicked!")
end
end
-- Create buttons inside the ScrollingFrame with individual functions
for i = 1, 5 do
local button = Instance.new("TextButton")
button.Size = UDim2.new(1, 0, 0, 30)
button.Position = UDim2.new(0, 0, 0, (i - 1) * 35)
button.BackgroundColor3 = Color3.new(0.4, 0.4, 0.4)
button.Text = "Button " .. i
button.Parent = scrollingFrame
-- Add individual functionality to each button
button.MouseButton1Click:Connect(function()
buttonClick(i)
end)
end