fix this script to make it so the buttons work, all the functions chat with players work, and so the startup message gets sent local Players = game:GetService("Players")
local HttpService = game:GetService("HttpService")
local TextChatService = game:GetService("TextChatService")
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local UserInputService = game:GetService("UserInputService")
-- Wait for LocalPlayer
local LocalPlayer = Players.LocalPlayer
if not LocalPlayer then
repeat task.wait() until Players.LocalPlayer
LocalPlayer = Players.LocalPlayer
end
-- Configuration
local CONFIG_FILE = "casino_bot_config.json"
local BASE_WIDTH = 520
local BASE_HEIGHT = 550 -- Increased height for new elements
-- Groq AI
local GROQ_API_KEY = "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" -- User provided key
local GROQ_URL = "https://api.groq.com/openai/v1/chat/completions"
local GROQ_MODEL = "llama-3.1-8b-instant"
-- Settings (will be loaded/saved)
local AI_SYSTEM_PROMPT = ""
local FORGER_STYLE = ""
local WHITELISTED_USERS = {}
local PlayerCoins = {}
-- State
local State = {
QuizActive = false,
GamblingActive = false,
CAIActive = false,
ForgerActive = false,
IsBotSending = false,
AI_Cooldown = false,
CurrentQuizTopic = nil,
CurrentQuestion = nil,
QuizCount = 0
}
local conversationHistory = {}
-- GUI References
local ScreenGui, MainFrame, ToggleButton
local ControlsFrame, SettingsFrame, ForgerFrame, TopicsFrame
local QuizBtn, GamblingBtn, AIBtn, ForgerBtn
local CoinDisplay, GamblingInput, RollButton, QuizStatusLabel, AIStatusLabel
-- ============== UTILITY ==============
local function sendChat(msg)
if TextChatService.ChatVersion == Enum.ChatVersion.TextChatService then
local ch = TextChatService.TextChannels:FindFirstChild("RBXGeneral")
if ch then ch:SendAsync(msg) return end
end
local dc = ReplicatedStorage:FindFirstChild("DefaultChatSystemChatEvents")
if dc and dc:FindFirstChild("SayMessageRequest") then
dc.SayMessageRequest:FireServer(msg, "All")
end
end
local function sanitize(text)
text = string.gsub(text, "[$ā¬Ā£Ā„]", " ")
text = string.gsub(text, "!", ".")
text = string.gsub(text, "[\r\n]+", " ")
return text
end
local function isWhitelisted(player)
if player.Name == LocalPlayer.Name then return true end
for _, n in ipairs(WHITELISTED_USERS) do
if string.lower(n) == string.lower(player.Name) then return true end
end
return false
end
local function getCoins(name) return PlayerCoins[name] or 1000 end
local function setCoins(name, amt) PlayerCoins[name] = amt end
local function updateCoinDisplay()
if CoinDisplay then
CoinDisplay.Text = "š° Coins: "..getCoins(LocalPlayer.Name)
end
end
local function updateAIStatus(statusText, color)
if AIStatusLabel then
AIStatusLabel.Text = "AI Status: "..statusText
AIStatusLabel.TextColor3 = color or Color3.fromRGB(150,150,150)
end
end
local function updateButtons()
local green = Color3.fromRGB(50,200,50)
local red = Color3.fromRGB(200,50,50)
local activeBg = Color3.fromRGB(40,40,55)
local inactiveBg = Color3.fromRGB(25,25,35)
QuizBtn.Text = State.QuizActive and "ON" or "OFF"
QuizBtn.BackgroundColor3 = State.QuizActive and green or red
GamblingBtn.Text = State.GamblingActive and "ON" or "OFF"
GamblingBtn.BackgroundColor3 = State.GamblingActive and green or red
AIBtn.Text = State.CAIActive and "ON" or "OFF"
AIBtn.BackgroundColor3 = State.CAIActive and green or red
ForgerBtn.Text = State.ForgerActive and "ON" or "OFF"
ForgerBtn.BackgroundColor3 = State.ForgerActive and green or red
-- Mode-specific panels visibility
local QuizStatusFrame = MainFrame:FindFirstChild("ModeStatusFrame"):FindFirstChild("QuizStatusFrame")
local GamblingFrame = MainFrame:FindFirstChild("ModeStatusFrame"):FindFirstChild("GamblingFrame")
if QuizStatusFrame then QuizStatusFrame.Visible = State.QuizActive end
if GamblingFrame then GamblingFrame.Visible = State.GamblingActive end
if ForgerFrame then ForgerFrame.Visible = State.ForgerActive end
-- Reset Quiz Status visibility if inactive
if not State.QuizActive and QuizStatusFrame and QuizStatusLabel then
QuizStatusLabel.Text = "No active quiz. Select a topic."
end
end
-- ============== SAVE/LOAD ==============
local function saveSettings()
-- This function relies on an external execution environment feature (writefile/readfile) not available in standard Roblox Luau.
-- It is kept as-is to preserve user intent for the environment the script runs in.
if not writefile then return end
pcall(function()
writefile(CONFIG_FILE, HttpService:JSONEncode({
Prompt = AI_SYSTEM_PROMPT,
ForgerStyle = FORGER_STYLE,
Whitelist = WHITELISTED_USERS,
Coins = PlayerCoins
}))
end)
end
local function loadSettings()
if not readfile or not isfile then return end
if not isfile(CONFIG_FILE) then return end
pcall(function()
local d = HttpService:JSONDecode(readfile(CONFIG_FILE))
AI_SYSTEM_PROMPT = d.Prompt or ""
FORGER_STYLE = d.ForgerStyle or ""
WHITELISTED_USERS = d.Whitelist or {}
PlayerCoins = d.Coins or {}
end)
end
loadSettings()
-- ============== GROQ AI ==============
local function callGroqAI(userMsg, playerName)
if not State.CAIActive or State.AI_Cooldown then sendChat("AI is on cooldown or inactive.") return end
if AI_SYSTEM_PROMPT == "" then sendChat("Set AI prompt in Settings!") return end
State.AI_Cooldown = true
updateAIStatus("Cooldown (2s)", Color3.fromRGB(255,150,0))
task.spawn(function()
table.insert(conversationHistory, {role="user", content=playerName..": "..userMsg})
while #conversationHistory > 6 do table.remove(conversationHistory, 1) end
local msgs = {{role="system", content=AI_SYSTEM_PROMPT}}
for _,m in ipairs(conversationHistory) do table.insert(msgs, m) end
local ok, res = pcall(function()
updateAIStatus("Sending...", Color3.fromRGB(100,200,255))
return request({
Url = GROQ_URL, Method = "POST",
Headers = {["Authorization"]="Bearer "..GROQ_API_KEY, ["Content-Type"]="application/json"},
Body = HttpService:JSONEncode({model=GROQ_MODEL, messages=msgs, max_tokens=200, temperature=0.8})
})
end)
if ok and res and res.StatusCode == 200 then
local data = HttpService:JSONDecode(res.Body)
if data.choices and data.choices[1] then
local reply = sanitize(data.choices[1].message.content)
if #reply > 200 then reply = string.sub(reply,1,197).."..." end
State.IsBotSending = true
sendChat(reply)
State.IsBotSending = false
table.insert(conversationHistory, {role="assistant", content=reply})
updateAIStatus("Ready (Success)", Color3.fromRGB(50,200,50))
else
updateAIStatus("Error: No reply", Color3.fromRGB(200,50,50))
end
else
updateAIStatus("Error: API Failed ("..(res and res.StatusCode or "PCall Error")..")", Color3.fromRGB(200,50,50))
end
task.delay(2, function()
State.AI_Cooldown = false
updateAIStatus("Ready", Color3.fromRGB(150,150,150))
end)
end)
end
local function forgeMessage(text)
if not State.ForgerActive or State.AI_Cooldown then sendChat("AI is on cooldown or inactive.") return end
if FORGER_STYLE == "" then sendChat("Set Forger style in Settings!") return end
State.AI_Cooldown = true
updateAIStatus("Cooldown (2s)", Color3.fromRGB(255,150,0))
task.spawn(function()
local prompt = "Rewrite this text in the style of: "..FORGER_STYLE..". Only output the transformed text, nothing else. Keep under 150 chars."
local ok, res = pcall(function()
updateAIStatus("Forging...", Color3.fromRGB(255,100,200))
return request({
Url = GROQ_URL, Method = "POST",
Headers = {["Authorization"]="Bearer "..GROQ_API_KEY, ["Content-Type"]="application/json"},
Body = HttpService:JSONEncode({
model=GROQ_MODEL,
messages={{role="system", content=prompt}, {role="user", content=text}},
max_tokens=150, temperature=0.9
})
})
end)
if ok and res and res.StatusCode == 200 then
local data = HttpService:JSONDecode(res.Body)
if data.choices and data.choices[1] then
local reply = sanitize(data.choices[1].message.content)
if #reply > 200 then reply = string.sub(reply,1,197).."..." end
State.IsBotSending = true
sendChat(reply)
State.IsBotSending = false
updateAIStatus("Ready (Success)", Color3.fromRGB(50,200,50))
else
updateAIStatus("Error: No reply", Color3.fromRGB(200,50,50))
end
else
updateAIStatus("Error: API Failed ("..(res and res.StatusCode or "PCall Error")..")", Color3.fromRGB(200,50,50))
end
task.delay(2, function()
State.AI_Cooldown = false
updateAIStatus("Ready", Color3.fromRGB(150,150,150))
end)
end)
end
-- ============== QUIZ ==============
local quizQuestions = {
["Roblox"] = {
{q="What year was Roblox released?", a="a", opts={a="2006",b="2004",c="2008",d="2010"}},
{q="Original name of Roblox?", a="c", opts={a="BlockCity",b="GoBlocks",c="DynaBlocks",d="BuildWorld"}},
},
["General"] = {
{q="Capital of France?", a="b", opts={a="London",b="Paris",c="Berlin",d="Rome"}},
{q="Largest planet?", a="a", opts={a="Jupiter",b="Saturn",c="Earth",d="Mars"}},
},
}
local function updateQuizStatusUI(msg, color)
if QuizStatusLabel then
QuizStatusLabel.Text = msg
QuizStatusLabel.TextColor3 = color or Color3.new(1,1,1)
end
end
local function startQuiz()
if not State.CurrentQuizTopic then
updateQuizStatusUI("Error: No topic selected.", Color3.fromRGB(200,50,50))
return
end
local qs = quizQuestions[State.CurrentQuizTopic]
if not qs or #qs == 0 then
updateQuizStatusUI("Error: No questions for topic.", Color3.fromRGB(200,50,50))
return
end
State.CurrentQuestion = qs[math.random(1,#qs)]
State.QuizCount = State.QuizCount + 1
local q = State.CurrentQuestion
sendChat("Q"..State.QuizCount..": "..q.q)
task.wait(0.8)
sendChat("A)"..q.opts.a.." B)"..q.opts.b.." C)"..q.opts.c.." D)"..q.opts.d)
updateQuizStatusUI("Q"..State.QuizCount.." ("..State.CurrentQuizTopic.."): "..q.q, Color3.new(1,1,1))
end
local function checkAnswer(player, msg)
if not State.CurrentQuestion then return end
local ans = string.lower(string.sub(msg,1,1))
if ans == State.CurrentQuestion.a then
sendChat("ā
Correct "..player.Name.." wins 50 coins!")
setCoins(player.Name, getCoins(player.Name) + 50)
updateCoinDisplay()
State.CurrentQuestion = nil
updateQuizStatusUI("ā
Correct! Next question in 2 seconds...", Color3.fromRGB(50,200,50))
task.delay(2, startQuiz)
end
end
-- ============== GAMBLING ==============
local function handleRoll(player, amt)
if not State.GamblingActive then sendChat("Gambling is currently inactive.") return end
if not amt or amt <= 0 then sendChat("Usage: !roll [amount]") return end
local coins = getCoins(player.Name)
if amt > coins then sendChat(player.Name.." needs more coins! ("..coins..")") return end
-- Clear input field if command came from GUI
if GamblingInput and player == LocalPlayer then GamblingInput.Text = "" end
local roll = math.random(1,100)
if roll > 50 then
setCoins(player.Name, coins + amt)
sendChat(player.Name.." rolled "..roll.." š WIN! +"..amt.." (Total:"..getCoins(player.Name)..")")
else
setCoins(player.Name, coins - amt)
sendChat(player.Name.." rolled "..roll.." š LOSS -"..amt.." (Total:"..getCoins(player.Name)..")")
end
updateCoinDisplay()
saveSettings()
end
-- ============== COMMANDS ==============
local function handleCommand(player, msg)
local args = {}
for w in msg:gmatch("%S+") do table.insert(args, w) end
local cmd = string.lower(args[1] or "")
local canUse = isWhitelisted(player)
if not canUse then return end
if cmd == "!roll" and State.GamblingActive then
local amt = tonumber(args[2])
handleRoll(player, amt)
elseif cmd == "!coins" then
sendChat(player.Name.." has "..getCoins(player.Name).." coins")
elseif cmd == "!give" and player == LocalPlayer then
local target, amt = args[2], tonumber(args[3])
if target and amt and amt > 0 then
setCoins(target, getCoins(target) + amt)
sendChat("Gave "..amt.." to "..target)
saveSettings()
end
elseif cmd == "!forge" and State.ForgerActive then
local text = string.sub(msg, 8)
if text ~= "" then forgeMessage(text) end
elseif cmd == "!ai" and State.CAIActive then
local text = string.sub(msg, 5)
if text ~= "" then callGroqAI(text, player.Name) end
elseif cmd == "!help" then
sendChat("Commands: !roll [amt], !coins, !give [player] [amt], !forge [text], !ai [text]")
end
end
-- ============== GUI ==============
local function createGUI()
-- Cleanup old
local old = LocalPlayer.PlayerGui:FindFirstChild("CasinoBotGUI")
if old then old:Destroy() end
ScreenGui = Instance.new("ScreenGui")
ScreenGui.Name = "CasinoBotGUI"
ScreenGui.ResetOnSpawn = false
ScreenGui.ZIndexBehavior = Enum.ZIndexBehavior.Sibling
ScreenGui.Parent = LocalPlayer.PlayerGui
-- Toggle Button (when minimized)
ToggleButton = Instance.new("TextButton")
ToggleButton.Size = UDim2.new(0,50,0,50)
ToggleButton.Position = UDim2.new(1,-60,0,10)
ToggleButton.BackgroundColor3 = Color3.fromRGB(40,40,50)
ToggleButton.Text = "š°"
ToggleButton.TextSize = 24
ToggleButton.Visible = false
ToggleButton.Parent = ScreenGui
Instance.new("UICorner", ToggleButton).CornerRadius = UDim.new(0,10)
-- Main Frame
MainFrame = Instance.new("Frame")
MainFrame.Size = UDim2.new(0, BASE_WIDTH, 0, BASE_HEIGHT)
MainFrame.Position = UDim2.new(0.5, -BASE_WIDTH/2, 0.5, -BASE_HEIGHT/2)
MainFrame.BackgroundColor3 = Color3.fromRGB(25,25,35)
MainFrame.BorderSizePixel = 0
MainFrame.Active = true
MainFrame.Parent = ScreenGui
Instance.new("UICorner", MainFrame).CornerRadius = UDim.new(0,12)
-- Title Bar (for dragging)
local titleBar = Instance.new("Frame")
titleBar.Size = UDim2.new(1,0,0,45)
titleBar.BackgroundColor3 = Color3.fromRGB(35,35,50)
titleBar.BorderSizePixel = 0
titleBar.Parent = MainFrame
Instance.new("UICorner", titleBar).CornerRadius = UDim.new(0,12)
local title = Instance.new("TextLabel")
title.Size = UDim2.new(0.6,0,1,0)
title.Position = UDim2.new(0,15,0,0)
title.BackgroundTransparency = 1
title.Text = "š° O's Casino Bot"
title.TextColor3 = Color3.fromRGB(255,215,0)
title.TextSize = 20
title.Font = Enum.Font.GothamBold
title.TextXAlignment = Enum.TextXAlignment.Left
title.Parent = titleBar
-- Minimize Button
local minBtn = Instance.new("TextButton")
minBtn.Size = UDim2.new(0,35,0,35)
minBtn.Position = UDim2.new(1,-40,0,5)
minBtn.BackgroundColor3 = Color3.fromRGB(200,60,60)
minBtn.Text = "ā"
minBtn.TextColor3 = Color3.new(1,1,1)
minBtn.TextSize = 20
minBtn.Font = Enum.Font.GothamBold
minBtn.Parent = titleBar
Instance.new("UICorner", minBtn).CornerRadius = UDim.new(0,8)
-- Settings Button
local settingsBtn = Instance.new("TextButton")
settingsBtn.Size = UDim2.new(0,90,0,35)
settingsBtn.Position = UDim2.new(1,-140,0,5)
settingsBtn.BackgroundColor3 = Color3.fromRGB(60,60,80)
settingsBtn.Text = "ā Settings"
settingsBtn.TextColor3 = Color3.new(1,1,1)
settingsBtn.TextSize = 14
settingsBtn.Font = Enum.Font.GothamBold
settingsBtn.Parent = titleBar
Instance.new("UICorner", settingsBtn).CornerRadius = UDim.new(0,8)
-- ============ CONTROLS FRAME (Main Panel) ============
ControlsFrame = Instance.new("Frame")
ControlsFrame.Size = UDim2.new(1,-20,1,-55)
ControlsFrame.Position = UDim2.new(0,10,0,50)
ControlsFrame.BackgroundTransparency = 1
ControlsFrame.Parent = MainFrame
local cLayout = Instance.new("UIListLayout")
cLayout.Padding = UDim.new(0,10)
cLayout.FillDirection = Enum.FillDirection.Vertical
cLayout.HorizontalAlignment = Enum.HorizontalAlignment.Center
cLayout.Parent = ControlsFrame
-- Mode Buttons Row
local modesRow = Instance.new("Frame")
modesRow.Size = UDim2.new(1,0,0,90)
modesRow.BackgroundTransparency = 1
modesRow.Parent = ControlsFrame
local modesLayout = Instance.new("UIListLayout")
modesLayout.FillDirection = Enum.FillDirection.Horizontal
modesLayout.Padding = UDim.new(0,10)
modesLayout.HorizontalAlignment = Enum.HorizontalAlignment.Center
modesLayout.Parent = modesRow
local function createModeBtn(name)
local f = Instance.new("Frame")
f.Size = UDim2.new(0,115,0,90)
f.BackgroundColor3 = Color3.fromRGB(40,40,55)
f.Parent = modesRow
Instance.new("UICorner", f).CornerRadius = UDim.new(0,10)
local l = Instance.new("TextLabel")
l.Size = UDim2.new(1,0,0,30)
l.Position = UDim2.new(0,0,0,5)
l.BackgroundTransparency = 1
l.Text = name
l.TextColor3 = Color3.new(1,1,1)
l.TextSize = 13
l.Font = Enum.Font.GothamBold
l.Parent = f
local b = Instance.new("TextButton")
b.Size = UDim2.new(0.8,0,0,40)
b.Position = UDim2.new(0.1,0,0,40)
b.BackgroundColor3 = Color3.fromRGB(200,50,50)
b.Text = "OFF"
b.TextColor3 = Color3.new(1,1,1)
b.TextSize = 16
b.Font = Enum.Font.GothamBold
b.Parent = f
Instance.new("UICorner", b).CornerRadius = UDim.new(0,8)
return b
end
QuizBtn = createModeBtn("Quiz")
GamblingBtn = createModeBtn("Gambling")
AIBtn = createModeBtn("Chat AI")
ForgerBtn = createModeBtn("Forger")
-- Coin Display
CoinDisplay = Instance.new("TextLabel")
CoinDisplay.Size = UDim2.new(1,0,0,30)
CoinDisplay.BackgroundTransparency = 1
CoinDisplay.Text = "š° Coins: 1000" -- Initial placeholder
CoinDisplay.TextColor3 = Color3.fromRGB(255,215,0)
CoinDisplay.TextSize = 18
CoinDisplay.Font = Enum.Font.GothamBold
CoinDisplay.Parent = ControlsFrame
-- Mode-Specific Container
local ModeSpecificContainer = Instance.new("Frame")
ModeSpecificContainer.Size = UDim2.new(1,0,1,-180) -- Fill remaining space
ModeSpecificContainer.BackgroundTransparency = 1
ModeSpecificContainer.Parent = ControlsFrame
local msLayout = Instance.new("UIListLayout")
msLayout.Padding = UDim.new(0,10)
msLayout.FillDirection = Enum.FillDirection.Vertical
msLayout.HorizontalAlignment = Enum.HorizontalAlignment.Center
msLayout.Parent = ModeSpecificContainer
-- Gambling UI Panel
GamblingFrame = Instance.new("Frame")
GamblingFrame.Name = "GamblingFrame"
GamblingFrame.Size = UDim2.new(1,0,0,100)
GamblingFrame.BackgroundColor3 = Color3.fromRGB(40,40,55)
GamblingFrame.Visible = false
GamblingFrame.Parent = ModeSpecificContainer
Instance.new("UICorner", GamblingFrame).CornerRadius = UDim.new(0,10)
local gambleLabel = Instance.new("TextLabel")
gambleLabel.Size = UDim2.new(1,0,0,25)
gambleLabel.Position = UDim2.new(0,0,0,5)
gambleLabel.BackgroundTransparency = 1
gambleLabel.Text = "š² Enter Bet Amount (50/50 roll):"
gambleLabel.TextColor3 = Color3.fromRGB(150,255,150)
gambleLabel.TextSize = 14
gambleLabel.Font = Enum.Font.GothamBold
gambleLabel.Parent = GamblingFrame
GamblingInput = Instance.new("TextBox")
GamblingInput.Size = UDim2.new(0.5,-10,0,45)
GamblingInput.Position = UDim2.new(0,10,0,40)
GamblingInput.BackgroundColor3 = Color3.fromRGB(55,55,70)
GamblingInput.TextColor3 = Color3.new(1,1,1)
GamblingInput.PlaceholderText = "Bet Amount"
GamblingInput.Text = ""
GamblingInput.TextSize = 14
GamblingInput.Font = Enum.Font.Gotham
GamblingInput.ClearTextOnFocus = false
GamblingInput.Parent = GamblingFrame
Instance.new("UICorner", GamblingInput).CornerRadius = UDim.new(0,8)
RollButton = Instance.new("TextButton")
RollButton.Size = UDim2.new(0.5,-10,0,45)
RollButton.Position = UDim2.new(0.5,0,0,40)
RollButton.BackgroundColor3 = Color3.fromRGB(255,165,0)
RollButton.Text = "ROLL!"
RollButton.TextColor3 = Color3.new(1,1,1)
RollButton.TextSize = 16
RollButton.Font = Enum.Font.GothamBold
RollButton.Parent = GamblingFrame
Instance.new("UICorner", RollButton).CornerRadius = UDim.new(0,8)
RollButton.MouseButton1Click:Connect(function()
local amt = tonumber(GamblingInput.Text)
handleRoll(LocalPlayer, amt)
end)
-- Quiz Status Panel
QuizStatusFrame = Instance.new("Frame")
QuizStatusFrame.Name = "QuizStatusFrame"
QuizStatusFrame.Size = UDim2.new(1,0,0,100)
QuizStatusFrame.BackgroundColor3 = Color3.fromRGB(40,40,55)
QuizStatusFrame.Visible = false
QuizStatusFrame.Parent = ModeSpecificContainer
Instance.new("UICorner", QuizStatusFrame).CornerRadius = UDim.new(0,10)
local quizTitle = Instance.new("TextLabel")
quizTitle.Size = UDim2.new(1,0,0,25)
quizTitle.BackgroundTransparency = 1
quizTitle.Text = "š§ Current Quiz Status"
quizTitle.TextColor3 = Color3.fromRGB(150,200,255)
quizTitle.TextSize = 14
quizTitle.Font = Enum.Font.GothamBold
quizTitle.Parent = QuizStatusFrame
QuizStatusLabel = Instance.new("TextLabel")
QuizStatusLabel.Size = UDim2.new(1,-20,0,60)
QuizStatusLabel.Position = UDim2.new(0,10,0,30)
QuizStatusLabel.BackgroundColor3 = Color3.fromRGB(55,55,70)
QuizStatusLabel.Text = "No active quiz. Select a topic."
QuizStatusLabel.TextColor3 = Color3.new(1,1,1)
QuizStatusLabel.TextSize = 12
QuizStatusLabel.Font = Enum.Font.Gotham
QuizStatusLabel.TextWrapped = true
QuizStatusLabel.TextXAlignment = Enum.TextXAlignment.Center
QuizStatusLabel.TextYAlignment = Enum.TextYAlignment.Center
QuizStatusLabel.Parent = QuizStatusFrame
Instance.new("UICorner", QuizStatusLabel).CornerRadius = UDim.new(0,8)
-- Forger Input Frame (Existing logic, now positioned in ModeSpecificContainer)
ForgerFrame = Instance.new("Frame")
ForgerFrame.Size = UDim2.new(1,0,0,130)
ForgerFrame.BackgroundColor3 = Color3.fromRGB(40,40,55)
ForgerFrame.Visible = false
ForgerFrame.Parent = ModeSpecificContainer
Instance.new("UICorner", ForgerFrame).CornerRadius = UDim.new(0,10)
local forgerLabel = Instance.new("TextLabel")
forgerLabel.Size = UDim2.new(1,0,0,25)
forgerLabel.Position = UDim2.new(0,0,0,5)
forgerLabel.BackgroundTransparency = 1
forgerLabel.Text = "āļø Type message to forge:"
forgerLabel.TextColor3 = Color3.fromRGB(255,200,100)
forgerLabel.TextSize = 14
forgerLabel.Font = Enum.Font.GothamBold
forgerLabel.Parent = ForgerFrame
local forgerInput = Instance.new("TextBox")
forgerInput.Size = UDim2.new(1,-20,0,45)
forgerInput.Position = UDim2.new(0,10,0,35)
forgerInput.BackgroundColor3 = Color3.fromRGB(55,55,70)
forgerInput.TextColor3 = Color3.new(1,1,1)
forgerInput.PlaceholderText = "Type here..."
forgerInput.Text = ""
forgerInput.TextSize = 14
forgerInput.Font = Enum.Font.Gotham
forgerInput.ClearTextOnFocus = false
forgerInput.Parent = ForgerFrame
Instance.new("UICorner", forgerInput).CornerRadius = UDim.new(0,8)
local forgerSendBtn = Instance.new("TextButton")
forgerSendBtn.Size = UDim2.new(1,-20,0,35)
forgerSendBtn.Position = UDim2.new(0,10,0,88)
forgerSendBtn.BackgroundColor3 = Color3.fromRGB(80,180,80)
forgerSendBtn.Text = "š„ FORGE & SEND"
forgerSendBtn.TextColor3 = Color3.new(1,1,1)
forgerSendBtn.TextSize = 15
forgerSendBtn.Font = Enum.Font.GothamBold
forgerSendBtn.Parent = ForgerFrame
Instance.new("UICorner", forgerSendBtn).CornerRadius = UDim.new(0,8)
forgerSendBtn.MouseButton1Click:Connect(function()
if forgerInput.Text ~= "" then
forgeMessage(forgerInput.Text)
forgerInput.Text = ""
end
end)
forgerInput.FocusLost:Connect(function(enter)
if enter and forgerInput.Text ~= "" then
forgeMessage(forgerInput.Text)
forgerInput.Text = ""
end
end)
-- AI Status Label (Added status indicator)
AIStatusLabel = Instance.new("TextLabel")
AIStatusLabel.Size = UDim2.new(1,0,0,20)
AIStatusLabel.BackgroundTransparency = 1
AIStatusLabel.Text = "AI Status: Ready"
AIStatusLabel.TextColor3 = Color3.fromRGB(150,150,150)
AIStatusLabel.TextSize = 12
AIStatusLabel.Font = Enum.Font.Gotham
AIStatusLabel.Parent = ModeSpecificContainer
-- Info Label (placed outside the main layout for fixed bottom position)
local infoLabel = Instance.new("TextLabel")
infoLabel.Size = UDim2.new(1,0,0,25)
infoLabel.Position = UDim2.new(0,0,1,-25)
infoLabel.BackgroundTransparency = 1
infoLabel.Text = "Press K to toggle | Whitelisted users can use !commands"
infoLabel.TextColor3 = Color3.fromRGB(120,120,140)
infoLabel.TextSize = 12
infoLabel.Font = Enum.Font.Gotham
infoLabel.Parent = ControlsFrame
-- ============ SETTINGS FRAME ============
SettingsFrame = Instance.new("ScrollingFrame")
SettingsFrame.Size = UDim2.new(1,-20,1,-55)
SettingsFrame.Position = UDim2.new(0,10,0,50)
SettingsFrame.BackgroundTransparency = 1
SettingsFrame.ScrollBarThickness = 6
SettingsFrame.CanvasSize = UDim2.new(0,0,0,550)
SettingsFrame.Visible = false
SettingsFrame.Parent = MainFrame
local sLayout = Instance.new("UIListLayout")
sLayout.Padding = UDim.new(0,12)
sLayout.HorizontalAlignment = Enum.HorizontalAlignment.Center
sLayout.Parent = SettingsFrame
local function createSettingLabel(text)
local l = Instance.new("TextLabel")
l.Size = UDim2.new(1,0,0,22)
l.BackgroundTransparency = 1
l.Text = text
l.TextColor3 = Color3.new(1,1,1)
l.TextXAlignment = Enum.TextXAlignment.Left
l.TextSize = 14
l.Font = Enum.Font.GothamBold
l.Parent = SettingsFrame
end
local function createSettingInput(placeholder, initialText)
local t = Instance.new("TextBox")
t.Size = UDim2.new(1,0,0,45)
t.BackgroundColor3 = Color3.fromRGB(45,45,60)
t.TextColor3 = Color3.new(1,1,1)
t.PlaceholderText = placeholder
t.Text = initialText or ""
t.TextSize = 12
t.Font = Enum.Font.Gotham
t.ClearTextOnFocus = false
t.TextWrapped = true
t.Parent = SettingsFrame
Instance.new("UICorner", t).CornerRadius = UDim.new(0,8)
return t
end
local function createSettingButton(text, color, callback)
local b = Instance.new("TextButton")
b.Size = UDim2.new(1,0,0,35)
b.BackgroundColor3 = color
b.Text = text
b.TextColor3 = Color3.new(1,1,1)
b.TextSize = 14
b.Font = Enum.Font.GothamBold
b.Parent = SettingsFrame
Instance.new("UICorner", b).CornerRadius = UDim.new(0,8)
b.MouseButton1Click:Connect(callback)
return b
end
-- Back Button
createSettingButton("ā Back to Controls", Color3.fromRGB(80,80,100), function()
SettingsFrame.Visible = false
ControlsFrame.Visible = true
settingsBtn.Visible = true
TopicsFrame.Visible = false
updateButtons() -- Re-check status on returning
end)
-- Reset Memory
createSettingButton("šļø Reset AI Memory", Color3.fromRGB(200,100,50), function()
conversationHistory = {}
sendChat("AI memory cleared!")
end)
-- AI Prompt
createSettingLabel("š¬ Chat AI System Prompt:")
local promptInput = createSettingInput("e.g. You are a friendly robot...", AI_SYSTEM_PROMPT)
createSettingButton("š¾ Save AI Prompt", Color3.fromRGB(50,180,50), function()
AI_SYSTEM_PROMPT = promptInput.Text
saveSettings()
sendChat("AI Prompt saved!")
end)
-- Forger Style
createSettingLabel("āļø Chat Forger Style:")
local styleInput = createSettingInput("e.g. uwu anime girl, pirate, shakespeare", FORGER_STYLE)
createSettingButton("š¾ Save Forger Style", Color3.fromRGB(180,100,200), function()
FORGER_STYLE = styleInput.Text
saveSettings()
sendChat("Forger style saved!")
end)
-- Whitelist
createSettingLabel("š„ Whitelisted Users (comma separated):")
local whitelistInput = createSettingInput("e.g. Player1, Player2", table.concat(WHITELISTED_USERS, ", "))
createSettingButton("š¾ Save Whitelist", Color3.fromRGB(100,150,255), function()
WHITELISTED_USERS = {}
for name in string.gmatch(whitelistInput.Text, "([^,]+)") do
local trimmed = string.gsub(name, "^%s*(.-)%s*$", "%1")
if trimmed ~= "" then table.insert(WHITELISTED_USERS, trimmed) end
end
saveSettings()
sendChat("Whitelist saved! ("..#WHITELISTED_USERS.." users)")
end)
-- Topics Frame (for quiz)
TopicsFrame = Instance.new("Frame")
TopicsFrame.Size = UDim2.new(0,BASE_WIDTH,0,120)
TopicsFrame.Position = UDim2.new(0.5,-BASE_WIDTH/2,0.5,BASE_HEIGHT/2+10)
TopicsFrame.BackgroundColor3 = Color3.fromRGB(30,30,45)
TopicsFrame.Visible = false
TopicsFrame.Parent = ScreenGui
Instance.new("UICorner", TopicsFrame).CornerRadius = UDim.new(0,10)
local topicsTitle = Instance.new("TextLabel")
topicsTitle.Size = UDim2.new(1,0,0,25)
topicsTitle.BackgroundTransparency = 1
topicsTitle.Text = "Select a Quiz Topic:"
topicsTitle.TextColor3 = Color3.fromRGB(255,215,0)
topicsTitle.TextSize = 16
topicsTitle.Font = Enum.Font.GothamBold
topicsTitle.Parent = TopicsFrame
local topicsList = Instance.new("Frame")
topicsList.Size = UDim2.new(1,-20,0,70)
topicsList.Position = UDim2.new(0,10,0,35)
topicsList.BackgroundTransparency = 1
topicsList.Parent = TopicsFrame
local topicsLayout = Instance.new("UIListLayout")
topicsLayout.FillDirection = Enum.FillDirection.Horizontal
topicsLayout.Padding = UDim.new(0,10)
topicsLayout.HorizontalAlignment = Enum.HorizontalAlignment.Center
topicsLayout.Parent = topicsList
-- ============ BUTTON CONNECTIONS ============
local function disableAll()
State.QuizActive = false
State.GamblingActive = false
State.CAIActive = false
State.ForgerActive = false
State.CurrentQuizTopic = nil
State.CurrentQuestion = nil
TopicsFrame.Visible = false
updateButtons()
end
local function showTopics()
-- Clear previous topic buttons
for _,c in ipairs(topicsList:GetChildren()) do
if c:IsA("TextButton") then c:Destroy() end
end
for topic,_ in pairs(quizQuestions) do
local tb = Instance.new("TextButton")
tb.Size = UDim2.new(0,100,0,35)
tb.BackgroundColor3 = Color3.fromRGB(60,60,80)
tb.Text = topic
tb.TextColor3 = Color3.new(1,1,1)
tb.TextSize = 14
tb.Font = Enum.Font.GothamBold
tb.Parent = topicsList
Instance.new("UICorner", tb).CornerRadius = UDim.new(0,8)
tb.MouseButton1Click:Connect(function()
State.CurrentQuizTopic = topic
TopicsFrame.Visible = false
updateQuizStatusUI("Selected topic: "..topic, Color3.fromRGB(150,200,255))
sendChat("Starting "..topic.." quiz! Answer A, B, C, or D in chat.")
task.wait(1)
startQuiz()
end)
end
TopicsFrame.Visible = true
end
QuizBtn.MouseButton1Click:Connect(function()
if State.QuizActive then
disableAll()
updateQuizStatusUI("Quiz Inactive.", Color3.fromRGB(200,50,50))
else
disableAll(); State.QuizActive = true; updateButtons(); showTopics()
updateQuizStatusUI("Select a topic above to start.", Color3.fromRGB(255,215,0))
end
end)
GamblingBtn.MouseButton1Click:Connect(function()
if State.GamblingActive then
disableAll()
else
disableAll(); State.GamblingActive = true; updateButtons(); sendChat("Gambling ON! Use the Roll Panel below or !roll [amount]")
end
end)
AIBtn.MouseButton1Click:Connect(function()
if State.CAIActive then
disableAll()
else
disableAll(); State.CAIActive = true; updateButtons(); conversationHistory = {}; sendChat("Chat AI ON! Say !ai [message]")
end
end)
ForgerBtn.MouseButton1Click:Connect(function()
if State.ForgerActive then
disableAll()
else
disableAll(); State.ForgerActive = true; updateButtons(); sendChat("Forger ON! Use the panel below or !forge [text]")
end
end)
-- Settings button
settingsBtn.MouseButton1Click:Connect(function()
ControlsFrame.Visible = false
SettingsFrame.Visible = true
settingsBtn.Visible = false
TopicsFrame.Visible = false
end)
-- Minimize/Toggle
local function toggleGUI()
MainFrame.Visible = not MainFrame.Visible
ToggleButton.Visible = not MainFrame.Visible
if not MainFrame.Visible then TopicsFrame.Visible = false end
end
minBtn.MouseButton1Click:Connect(toggleGUI)
ToggleButton.MouseButton1Click:Connect(toggleGUI)
-- Dragging
local dragging, dragStart, startPos = false, nil, nil
titleBar.InputBegan:Connect(function(input)
if input.UserInputType == Enum.UserInputType.MouseButton1 or input.UserInputType == Enum.UserInputType.Touch then
dragging = true
dragStart = input.Position
startPos = MainFrame.Position
end
end)
titleBar.InputEnded:Connect(function(input)
if input.UserInputType == Enum.UserInputType.MouseButton1 or input.UserInputType == Enum.UserInputType.Touch then
dragging = false
end
end)
UserInputService.InputChanged:Connect(function(input)
if dragging and (input.UserInputType == Enum.UserInputType.MouseMovement or input.UserInputType == Enum.UserInputType.Touch) then
local delta = input.Position - dragStart
-- Update MainFrame position
MainFrame.Position = UDim2.new(startPos.X.Scale, startPos.X.Offset + delta.X, startPos.Y.Scale, startPos.Y.Offset + delta.Y)
-- Recalculate TopicsFrame position relative to MainFrame's new position
-- This keeps the TopicsFrame below the MainFrame
TopicsFrame.Position = UDim2.new(
MainFrame.Position.X.Scale,
MainFrame.Position.X.Offset + (BASE_WIDTH/2) - (TopicsFrame.Size.X.Offset/2), -- Center X relative to MainFrame
MainFrame.Position.Y.Scale,
MainFrame.Position.Y.Offset + BASE_HEIGHT + 10 -- Offset Y below MainFrame
)
end
end)
-- K Hotkey
UserInputService.InputBegan:Connect(function(input, processed)
if processed then return end
if input.KeyCode == Enum.KeyCode.K then
toggleGUI()
end
end)
updateCoinDisplay()
updateButtons()
updateAIStatus("Ready", Color3.fromRGB(150,150,150))
return ScreenGui
end
-- ============== MESSAGE HANDLER ==============
local function onMessage(player, msg)
if State.IsBotSending then return end
local isCmd = string.sub(msg, 1, 1) == "!"
if isCmd then
handleCommand(player, msg)
return
end
-- Check for quiz answers only if a question is active and it's not the bot talking
if player ~= LocalPlayer then
if State.QuizActive and State.CurrentQuestion then
checkAnswer(player, msg)
elseif State.CAIActive then
callGroqAI(msg, player.Name)
end
end
end
-- ============== STARTUP ==============
local gui = createGUI()
if gui then
print("š° O's Casino Bot loaded!")
sendChat("O's Casino Bot Active!")
-- Function to connect player chat events
local function connectPlayerChat(p)
-- Attempt to use the newer TextChatService first
local chatEvent = p:FindFirstChild("Chatted")
if chatEvent then
chatEvent:Connect(function(msg) onMessage(p, msg) end)
end
end
for _, p in ipairs(Players:GetPlayers()) do
connectPlayerChat(p)
end
Players.PlayerAdded:Connect(connectPlayerChat)
-- Fallback/Alternative method for message listening (TextChatService)
if TextChatService and TextChatService.ChatVersion == Enum.ChatVersion.TextChatService then
pcall(function()
TextChatService.OnIncomingMessage:Connect(function(m)
if m.Status == Enum.TextChatMessageStatus.Success and m.TextSource and m.TextSource:IsA("TextSource") then
local p = Players:GetPlayerByUserId(m.TextSource.UserId)
if p then onMessage(p, m.Text) end
end
end)
end)
end
end