-- Auto Train GUI
-- Creates a simple GUI to select world and machine number for auto training
-- Initialize global variables
_G.testing = false
_G.worldNumber = 3
_G.machineNumber = 1
-- Create GUI
local ScreenGui = Instance.new("ScreenGui")
local MainFrame = Instance.new("Frame")
local UICorner = Instance.new("UICorner")
local Title = Instance.new("TextLabel")
local WorldFrame = Instance.new("Frame")
local WorldTitle = Instance.new("TextLabel")
local World1Button = Instance.new("TextButton")
local World2Button = Instance.new("TextButton")
local World3Button = Instance.new("TextButton")
local MachineFrame = Instance.new("Frame")
local MachineTitle = Instance.new("TextLabel")
local MachineInput = Instance.new("TextBox")
local StatusLabel = Instance.new("TextLabel")
local StartButton = Instance.new("TextButton")
local StopButton = Instance.new("TextButton")
-- Parent GUI to player
ScreenGui.Parent = game:GetService("CoreGui")
ScreenGui.ZIndexBehavior = Enum.ZIndexBehavior.Sibling
-- Main Frame
MainFrame.Name = "MainFrame"
MainFrame.Parent = ScreenGui
MainFrame.BackgroundColor3 = Color3.fromRGB(40, 40, 40)
MainFrame.Position = UDim2.new(0.5, -150, 0.5, -125)
MainFrame.Size = UDim2.new(0, 300, 0, 250)
MainFrame.Active = true
MainFrame.Draggable = true
-- Add corner radius to main frame
UICorner.Parent = MainFrame
-- Title
Title.Name = "Title"
Title.Parent = MainFrame
Title.BackgroundTransparency = 1
Title.Position = UDim2.new(0, 0, 0, 10)
Title.Size = UDim2.new(1, 0, 0, 30)
Title.Font = Enum.Font.SourceSansBold
Title.Text = "Auto Train GUI"
Title.TextColor3 = Color3.fromRGB(255, 255, 255)
Title.TextSize = 22
-- World Selection Frame
WorldFrame.Name = "WorldFrame"
WorldFrame.Parent = MainFrame
WorldFrame.BackgroundTransparency = 1
WorldFrame.Position = UDim2.new(0, 20, 0, 50)
WorldFrame.Size = UDim2.new(0, 260, 0, 60)
-- World Title
WorldTitle.Name = "WorldTitle"
WorldTitle.Parent = WorldFrame
WorldTitle.BackgroundTransparency = 1
WorldTitle.Position = UDim2.new(0, 0, 0, 0)
WorldTitle.Size = UDim2.new(1, 0, 0, 20)
WorldTitle.Font = Enum.Font.SourceSans
WorldTitle.Text = "Select World:"
WorldTitle.TextColor3 = Color3.fromRGB(255, 255, 255)
WorldTitle.TextSize = 16
WorldTitle.TextXAlignment = Enum.TextXAlignment.Left
-- World Buttons
World1Button.Name = "World1Button"
World1Button.Parent = WorldFrame
World1Button.BackgroundColor3 = Color3.fromRGB(60, 60, 60)
World1Button.Position = UDim2.new(0, 0, 0, 25)
World1Button.Size = UDim2.new(0, 80, 0, 30)
World1Button.Font = Enum.Font.SourceSans
World1Button.Text = "World 1"
World1Button.TextColor3 = Color3.fromRGB(255, 255, 255)
World1Button.TextSize = 16
World2Button.Name = "World2Button"
World2Button.Parent = WorldFrame
World2Button.BackgroundColor3 = Color3.fromRGB(60, 60, 60)
World2Button.Position = UDim2.new(0, 90, 0, 25)
World2Button.Size = UDim2.new(0, 80, 0, 30)
World2Button.Font = Enum.Font.SourceSans
World2Button.Text = "World 2"
World2Button.TextColor3 = Color3.fromRGB(255, 255, 255)
World2Button.TextSize = 16
World3Button.Name = "World3Button"
World3Button.Parent = WorldFrame
World3Button.BackgroundColor3 = Color3.fromRGB(50, 150, 50) -- Default selected
World3Button.Position = UDim2.new(0, 180, 0, 25)
World3Button.Size = UDim2.new(0, 80, 0, 30)
World3Button.Font = Enum.Font.SourceSans
World3Button.Text = "World 3"
World3Button.TextColor3 = Color3.fromRGB(255, 255, 255)
World3Button.TextSize = 16
-- Machine Selection Frame
MachineFrame.Name = "MachineFrame"
MachineFrame.Parent = MainFrame
MachineFrame.BackgroundTransparency = 1
MachineFrame.Position = UDim2.new(0, 20, 0, 120)
MachineFrame.Size = UDim2.new(0, 260, 0, 60)
-- Machine Title
MachineTitle.Name = "MachineTitle"
MachineTitle.Parent = MachineFrame
MachineTitle.BackgroundTransparency = 1
MachineTitle.Position = UDim2.new(0, 0, 0, 0)
MachineTitle.Size = UDim2.new(1, 0, 0, 20)
MachineTitle.Font = Enum.Font.SourceSans
MachineTitle.Text = "Machine Number (1-12):"
MachineTitle.TextColor3 = Color3.fromRGB(255, 255, 255)
MachineTitle.TextSize = 16
MachineTitle.TextXAlignment = Enum.TextXAlignment.Left
-- Machine Input
MachineInput.Name = "MachineInput"
MachineInput.Parent = MachineFrame
MachineInput.BackgroundColor3 = Color3.fromRGB(60, 60, 60)
MachineInput.Position = UDim2.new(0, 0, 0, 25)
MachineInput.Size = UDim2.new(1, 0, 0, 30)
MachineInput.Font = Enum.Font.SourceSans
MachineInput.Text = "1"
MachineInput.TextColor3 = Color3.fromRGB(255, 255, 255)
MachineInput.TextSize = 16
-- Status Label
StatusLabel.Name = "StatusLabel"
StatusLabel.Parent = MainFrame
StatusLabel.BackgroundTransparency = 1
StatusLabel.Position = UDim2.new(0, 20, 0, 185)
StatusLabel.Size = UDim2.new(0, 260, 0, 20)
StatusLabel.Font = Enum.Font.SourceSans
StatusLabel.Text = "Status: Ready"
StatusLabel.TextColor3 = Color3.fromRGB(255, 255, 255)
StatusLabel.TextSize = 16
StatusLabel.TextXAlignment = Enum.TextXAlignment.Left
-- Start Button
StartButton.Name = "StartButton"
StartButton.Parent = MainFrame
StartButton.BackgroundColor3 = Color3.fromRGB(50, 150, 50)
StartButton.Position = UDim2.new(0, 20, 0, 210)
StartButton.Size = UDim2.new(0, 125, 0, 30)
StartButton.Font = Enum.Font.SourceSansBold
StartButton.Text = "START"
StartButton.TextColor3 = Color3.fromRGB(255, 255, 255)
StartButton.TextSize = 16
-- Stop Button
StopButton.Name = "StopButton"
StopButton.Parent = MainFrame
StopButton.BackgroundColor3 = Color3.fromRGB(150, 50, 50)
StopButton.Position = UDim2.new(0, 155, 0, 210)
StopButton.Size = UDim2.new(0, 125, 0, 30)
StopButton.Font = Enum.Font.SourceSansBold
StopButton.Text = "STOP"
StopButton.TextColor3 = Color3.fromRGB(255, 255, 255)
StopButton.TextSize = 16
-- Function to update button colors when selected
local function updateWorldButtons(selected)
World1Button.BackgroundColor3 = Color3.fromRGB(60, 60, 60)
World2Button.BackgroundColor3 = Color3.fromRGB(60, 60, 60)
World3Button.BackgroundColor3 = Color3.fromRGB(60, 60, 60)
if selected == 1 then
World1Button.BackgroundColor3 = Color3.fromRGB(50, 150, 50)
elseif selected == 2 then
World2Button.BackgroundColor3 = Color3.fromRGB(50, 150, 50)
elseif selected == 3 then
World3Button.BackgroundColor3 = Color3.fromRGB(50, 150, 50)
end
end
-- World button click events
World1Button.MouseButton1Click:Connect(function()
_G.worldNumber = 1
updateWorldButtons(1)
StatusLabel.Text = "Status: Selected World 1"
end)
World2Button.MouseButton1Click:Connect(function()
_G.worldNumber = 2
updateWorldButtons(2)
StatusLabel.Text = "Status: Selected World 2"
end)
World3Button.MouseButton1Click:Connect(function()
_G.worldNumber = 3
updateWorldButtons(3)
StatusLabel.Text = "Status: Selected World 3"
end)
-- Machine input validation
MachineInput.FocusLost:Connect(function(enterPressed)
local inputText = MachineInput.Text
local machineNum = tonumber(inputText)
if machineNum then
if machineNum >= 1 and machineNum <= 12 then
_G.machineNumber = machineNum
StatusLabel.Text = "Status: Set to Machine " .. machineNum
else
MachineInput.Text = "1"
_G.machineNumber = 1
StatusLabel.Text = "Status: Invalid number, reset to 1"
end
else
MachineInput.Text = "1"
_G.machineNumber = 1
StatusLabel.Text = "Status: Invalid input, reset to 1"
end
end)
-- Auto train function
local autoTrainRunning = false
local autoTrainConnection = nil
local function startAutoTrain()
if autoTrainRunning then return end
_G.testing = true
autoTrainRunning = true
autoTrainConnection = task.spawn(function()
local replicatedStorage = game:GetService("ReplicatedStorage")
local event = replicatedStorage:WaitForChild("Event")
local remoteEvent = event:WaitForChild("RemoteEvent")
local cToS = remoteEvent:WaitForChild("CToS")
local gameFolder = cToS:WaitForChild("Game")
local cStartTrain = gameFolder:WaitForChild("CStartTrain")
local cPlayerClick = gameFolder:WaitForChild("CPlayerClick")
-- First: start the training once
cStartTrain:FireServer(true, "Train_" .. _G.worldNumber .. "_" .. _G.machineNumber)
StatusLabel.Text = "Status: Started on World " .. _G.worldNumber .. ", Machine " .. _G.machineNumber
task.wait(0.2) -- small delay to let the server prepare
-- Second: keep clicking while toggle is true
while _G.testing do
local args = {
[1] = "Train_" .. _G.worldNumber .. "_" .. _G.machineNumber
}
cPlayerClick:FireServer(unpack(args))
task.wait(0.01) -- click speed
end
end)
end
local function stopAutoTrain()
_G.testing = false
autoTrainRunning = false
StatusLabel.Text = "Status: Stopped"
end
-- Button click events
StartButton.MouseButton1Click:Connect(function()
startAutoTrain()
end)
StopButton.MouseButton1Click:Connect(function()
stopAutoTrain()
end)
-- Initialize with World 3 selected
updateWorldButtons(3)