Hello, I’m trying to make a Roulette Payout system for my game, I barely understand the payout logic of the roulette in general and I can’t/didn’t find any solution anywhere, so I cannot seem to write this correctly, if you can tell me what is wrong, and how to fix it, I would appreciate it.
Thanks
Code:
local Payouts = {
["0"] = 35, -- Straight Up (1 number)
["1"] = 35,
["2"] = 35,
["3"] = 35,
["4"] = 35,
["5"] = 35,
["6"] = 35,
["7"] = 35,
["8"] = 35,
["9"] = 35,
["10"] = 35,
["11"] = 35,
["12"] = 35,
["13"] = 35,
["14"] = 35,
["15"] = 35,
["16"] = 35,
["17"] = 35,
["18"] = 35,
["19"] = 35,
["20"] = 35,
["21"] = 35,
["22"] = 35,
["23"] = 35,
["24"] = 35,
["25"] = 35,
["26"] = 35,
["27"] = 35,
["28"] = 35,
["29"] = 35,
["30"] = 35,
["31"] = 35,
["32"] = 35,
["33"] = 35,
["34"] = 35,
["35"] = 35,
["36"] = 35,
["Even"] = 2, -- Even (18 numbers) 1
["Odd"] = 2, -- Odd (18 numbers) 1
["Red"] = 2, -- Red (18 numbers) 1
["Black"] = 2, -- Black (18 numbers) 1
["Low"] = 2, -- Low (1-18) 1
["High"] = 2, -- High (19-36) 1
["Column"] = 2, -- Column (12 numbers)
["Dozen"] = 2, -- Dozen (12 numbers)
["Line"] = 5, -- Line (6 numbers)
["FiveNumber"] = 6, -- Five-number (0, 00, 1, 2, 3)
["Corner"] = 8, -- Corner (4 numbers)
["Street"] = 11, -- Street (3 numbers)
["Split"] = 17, -- Split (2 numbers)
}
local function DoRotationAndRandomPocket()
IsInRound = true
partB.Transparency = 0
partB.Position = OLDPOSITION
connection = game:GetService("RunService").Heartbeat:Connect(function(dt)
movePartB(dt)
end)
for i = 1, 100 do
Chosen = partA:FindFirstChild(tostring(math.random(0, 36)))
wait(0.05)
end
connection:Disconnect()
if Chosen and Chosen:IsA("BasePart") then
game:GetService("TweenService"):Create(partB, TweenInfo.new(0.5), {Position = Chosen.Position}):Play()
TheChosenPocket = Chosen
for _, player in ipairs(PlayersInRound) do
for _, playerChoice in ipairs(PlayersChoices) do
local playerName = playerChoice.Player
local chipValue = playerChoice.chip
local pocketNumber = playerChoice.PocketNumber
local PlayerPocketColor = playerChoice.PocketColor
local totalBet = player:FindFirstChild("RouletteBET")
if player.Name == playerName then
if totalBet and totalBet.Value > 0 then
totalBet = totalBet.Value
local betType = tonumber(TheChosenPocket.Name)
local payoutMultiplier = 0
if betType ~= nil then
payoutMultiplier = Payouts[tostring(betType)] or 0
elseif betType == 0 then
payoutMultiplier = Payouts["0"] or 0
elseif betType % 2 == 0 then -- Even
payoutMultiplier = Payouts["Even"] or 0
elseif betType % 2 == 1 then -- Odd
payoutMultiplier = Payouts["Odd"] or 0
elseif betType >= 1 and betType <= 18 then -- Low
payoutMultiplier = Payouts["Low"] or 0
elseif betType >= 19 and betType <= 36 then -- High
payoutMultiplier = Payouts["High"] or 0
elseif betType == 37 or betType == 38 then -- Five-number
payoutMultiplier = Payouts["FiveNumber"] or 0
elseif betType >= 1 and betType <= 34 then -- Street
payoutMultiplier = Payouts["Street"] or 0
elseif betType >= 1 and betType <= 33 then -- Corner
payoutMultiplier = Payouts["Corner"] or 0
elseif betType >= 1 and betType <= 30 then -- Line
payoutMultiplier = Payouts["Line"] or 0
elseif betType >= 1 and betType <= 24 then -- Dozen
payoutMultiplier = Payouts["Dozen"] or 0
elseif betType >= 1 and betType <= 17 then -- Split
payoutMultiplier = Payouts["Split"] or 0
else
warn("Invalid bet type:", betType)
end
local OldMultiplayer = payoutMultiplier
if TheChosenPocket.Color == Color3.fromRGB(0,0,0) then
payoutMultiplier = Payouts["Black"] * OldMultiplayer
elseif TheChosenPocket.Color == Color3.fromRGB(255,0,0) then
payoutMultiplier = Payouts["Red"] * OldMultiplayer
end
local ThePocketColor = (TheChosenPocket.Color == Color3.fromRGB(0, 0, 0)) and "Black" or "Red"
local totalPayout = totalBet * payoutMultiplier
print("Player:", playerName)
print("Chip Value:", chipValue)
print("Payout Multiplier:", payoutMultiplier)
print("Total Payout:", totalPayout)
print("Player betted on", {Pocket = pocketNumber, Color = PlayerPocketColor})
player.leaderstats.Money.Value += totalPayout
print(playerName .. " won " .. totalPayout .. " money based on their choice!")
end
player:FindFirstChild("IsInRound").Value = false
table.remove(PlayersInRound, table.find(PlayersInRound, player))
end
end
end
end
IsInRound = false
PlayersInRound = {}
PlayersChoices = {}
Owned = false
script.Parent.Trigger.BillboardGui.TextLabel.Text = OldTxt
script.Parent.TakenBy.Value = "None"
CD.Enabled = true
game:GetService("TweenService"):Create(script.Parent.Trigger.BillboardGui.TextLabel,TweenInfo.new(0.1),{TextColor3 = Color3.fromRGB(255, 255, 255)}):Play()
local BetFolder = script.Parent.Bets
for _, chip in ipairs(BetFolder:GetChildren()) do
chip:Destroy()
end
end