0% found this document useful (0 votes)
10 views4 pages

Gambling Script

patched

Uploaded by

wyoruu29k
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
10 views4 pages

Gambling Script

patched

Uploaded by

wyoruu29k
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 4

local Players = game:GetService("Players")

local ReplicatedStorage = game:GetService("ReplicatedStorage")


local updateremote = ReplicatedStorage:WaitForChild("CustomiseBooth")

-- Symbols for the slot machine


local slotSymbols = {"🍒", "🍋", "🍊", "⭐", "💎"}
local jackpotChance = 0.01 -- 1% chance to hit the jackpot

-- Function to update the booth with results


local function updateBoothText(text, imageId)
local success, err = pcall(function()
updateremote:FireServer("Update", {DescriptionText = text, ImageId =
imageId}) -- Include ImageId
end)
if not success then
warn("Failed to update booth text: " .. err)
wait(1) -- Wait a second before restarting if it fails
initializeCasino() -- Restart the casino if tagging occurs
end
end

-- Function to simulate slot machine spin


local function spinSlots()
return slotSymbols[math.random(1, #slotSymbols)], slotSymbols[math.random(1,
#slotSymbols)], slotSymbols[math.random(1, #slotSymbols)]
end

-- Function to update booth text with emojis


local function displaySlotResults(slot1, slot2, slot3, winnings, playerCurrency,
playerName)
local currentBalance = playerCurrency + winnings
if winnings > 0 then
updateBoothText("🎉 Jackpot! Congrats " .. playerName .. "!\n" .. slot1 .. "
| " .. slot2 .. " | " .. slot3 .. "\nYou won " .. winnings .. " coins.\nCurrent
balance: " .. currentBalance .. " coins.")
else
updateBoothText("😢 Sorry " .. playerName .. ", you lost.\n" .. slot1 .. "
| " .. slot2 .. " | " .. slot3 .. "\nBetter luck next time!\nCurrent balance: " ..
currentBalance .. " coins.")
end
end

-- Initialize player currency for each player


local playerCurrencies = {}
local isBetting = false -- Track if a bet is currently in progress
local gamblingActive = true -- Track if gambling is currently active

-- Player bets and spins the slot machine


local function onPlayerBet(player, betAmount)
if not gamblingActive then return end -- Prevent betting if gambling is closed
if isBetting then return end
local playerId = player.UserId
local playerName = player.DisplayName -- Get the player's display name
local playerCurrency = playerCurrencies[playerId] or 100 -- Starting currency
for the player

if playerCurrency >= betAmount and betAmount > 0 then


playerCurrency -= betAmount
playerCurrencies[playerId] = playerCurrency -- Update the player's currency
isBetting = true -- Mark betting in progress

local finalSlot1, finalSlot2, finalSlot3

-- Randomize the slots 5 times


for i = 1, 5 do
local slot1, slot2, slot3 = spinSlots()
updateBoothText(slot1 .. " | " .. slot2 .. " | " .. slot3) -- Show the
random result
wait(0.5) -- Wait briefly before the next spin (0.5 seconds)
if i == 5 then
finalSlot1, finalSlot2, finalSlot3 = slot1, slot2, slot3 -- Save
the final result
end
end

local winnings = 0
local isJackpot = false

-- Check for jackpot


if finalSlot1 == finalSlot2 and finalSlot2 == finalSlot3 then
winnings = math.random(500, 1000) -- Jackpot winnings if all three
slots match
end

-- Add winnings to player's currency after a successful bet


playerCurrency += winnings -- Update the player's currency with winnings
playerCurrencies[playerId] = playerCurrency -- Save updated currency

-- Display the final results without tagging


displaySlotResults(finalSlot1, finalSlot2, finalSlot3, winnings,
playerCurrency, playerName)

wait(3) -- Wait for 3 seconds before allowing the next bet


updateBoothText("🤑 Place !bet (Amount) to gamble!") -- Reset the booth text
isBetting = false -- Mark betting as finished
elseif betAmount == 0 then
-- No message when betting 0, simply return
else
updateBoothText("❌ Not enough coins! You have " .. playerCurrency .. "
coins.")
wait(3) -- Display for 3 seconds
updateBoothText("🤑 Place !bet (Amount) to gamble!") -- Reset the booth text
after 3 seconds
end
end

-- Player chat handling to place a bet


local function onPlayerChatted(player, message)
local betAmount = tonumber(message:match("^!bet (%d+)$")) -- Detects if the
message is in the format "!bet <amount>"
local endCommand = message:match("^!end gamble$")
local restartCommand = message:match("^!restart gamble$")
local coinsCommand = message:match("^!coins (%S+) (%d+)$") -- Updated to
capture username and amount
local fixCommand = message:match("^!fix$")
local infoCommand = message:match("^!info$")

if betAmount then
onPlayerBet(player, betAmount)
elseif endCommand and player.UserId == 6210009769 then
updateBoothText("🚪 Gambling closing...") -- Updated message
isBetting = false -- Prevent further betting
gamblingActive = false -- Mark gambling as closed
wait(10) -- Allow the message to show for a bit
updateBoothText("🚫 Gambling has been closed.")
elseif restartCommand and player.UserId == 6210009769 then
updateBoothText("🔄 Gambling restarting... Please wait.")
gamblingActive = true -- Allow gambling to restart
initializeCasino() -- Restart the casino
elseif coinsCommand then
local targetUsername, amountStr = coinsCommand:match("^!coins (%S+) (%d+)
$")
local amount = tonumber(amountStr)
if amount then
-- Find the target player by username
local targetPlayer = Players:GetPlayers()
for _, playerInGame in ipairs(targetPlayer) do
if playerInGame.DisplayName:lower() == targetUsername:lower() or
playerInGame.Name:lower() == targetUsername:lower() then
playerCurrencies[playerInGame.UserId] =
(playerCurrencies[playerInGame.UserId] or 0) + amount
updateBoothText("💰 " .. playerInGame.DisplayName .. " has
received " .. amount .. " coins. Current balance: " ..
playerCurrencies[playerInGame.UserId] .. " coins.")
return
end
end
updateBoothText("👤 Player '" .. targetUsername .. "' not found.") --
Player not found
end
elseif fixCommand and player.UserId == 6210009769 then
updateBoothText("🔧 Fixing tagging issues...") -- Optional message while
fixing
wait(1) -- Allow time for the message to show
updateBoothText("🤑 Place !bet (Amount) to gamble!") -- Reset the booth text
elseif infoCommand and player.UserId == 6210009769 then
isBetting = true -- Pause betting without message
updateBoothText("📜 Made and scripted by barcode guy. Suggestions for
scripts are welcome!", "77372374661565") -- Added image ID here
wait(5) -- Display for 5 seconds
updateBoothText("🤑 Place !bet (Amount) to gamble!", "") -- Reset the booth
text without image
isBetting = false -- Resume betting
end
end

-- Initialize the casino


local function initializeCasino()
updateBoothText("🤑 Place !bet (Amount) to gamble!") -- Initial prompt for
betting
for _, player in pairs(Players:GetPlayers()) do
playerCurrencies[player.UserId] = 100 -- Initialize currency for existing
players
end
end

-- Connect players to the chat command


Players.PlayerAdded:Connect(function(player)
playerCurrencies[player.UserId] = 100 -- Initialize currency for new players
player.Chatted:Connect(function(message)
onPlayerChatted(player, message)
end)
end)

-- Ensure current players can bet if they are already in the game
for _, player in ipairs(Players:GetPlayers()) do
player.Chatted:Connect(function(message)
onPlayerChatted(player, message)
end)
end

initializeCasino() -- Call the initialize function to start the casino

You might also like