I’m working with a team that invited me to work on an RNG-type game. I don’t like copies of games, but I was asked and I couldn’t refuse. Anyway, here’s the code:
local TweenService = game:GetService("TweenService")
local diceevent = game:GetService("ReplicatedStorage").Dice
local quickdice = game:GetService("ReplicatedStorage").QuickDice
local luck = false
local auraScrollSpeed = 0.3
local module = require(game.ReplicatedStorage.Rolls)
local auras = {
{name = "Common", OneIn = 2, TextColor = Color3.new(255, 255, 255)},
{name = "Uncommon", OneIn = 3, TextColor = Color3.new(0, 1, 0.4)},
{name = "Glitch", OneIn = 5, TextColor = Color3.new(1, 0, 0.901961)},
{name = "Honeeey", OneIn = 3000, TextColor = Color3.new(1, 0.74902, 0)}
}
local tweenInfo = TweenInfo.new(0.35)
local countertext = 0
local ended = false
diceevent.OnServerEvent:Connect(function(player)
local character = player.Character
local rootpart = character:WaitForChild("HumanoidRootPart")
local gui = player.PlayerGui.Main.DiceScreen
local rollbutton = gui.Dice
local skipbutton = gui.Skip
local equipbutton = gui.Equip
local lucktext = gui.Dice.Luck
local spinmsg = gui.SpinMSG
local setting = gui.Parent.Settings.AutoSkip.AutoSkipSet
local auramsg = spinmsg.RolledAura
local spinscounter = character:WaitForChild("RollsCounter")
local guiplayer = rootpart:WaitForChild("GUIPlayers")
local curentaura = character:WaitForChild("CurrentAura")
local tween0 = TweenService:Create(skipbutton, tweenInfo, {Position = UDim2.new(0.346, 0, 0.75, 0)})
local tween1 = TweenService:Create(equipbutton, tweenInfo, {Position = UDim2.new(0.546, 0, 0.75, 0)})
spinmsg.Visible = true
auramsg.Visible = true
gui.Transparency = 0.65
rollbutton.Visible = false
local valuesomelol = Instance.new("IntValue", auramsg.ChanceForAura)
valuesomelol.Name = "OneInValue"
local textonein = Instance.new("IntValue", setting)
textonein.Name = "TextOneIn"
textonein.Value = setting.Text
local tweenInfoROLL = TweenInfo.new(0.3)
local tweenROLL = TweenService:Create(auramsg, tweenInfoROLL, {Position = UDim2.new(0.2, 0,5.15, 0)})
while task.wait(auraScrollSpeed) do
local quickrolls = character:GetAttribute("QK")
auramsg.Position = UDim2.new(0.2, 0, 4.75, 0)
countertext = countertext + 1
print(auraScrollSpeed)
if quickrolls == true then
auraScrollSpeed = 0.1
else
auraScrollSpeed += 0.04
end
local color
tweenROLL:Play()
local randomValue = math.random()
if countertext < 9 then
module.Rolls(auramsg, randomValue, auras)
else
module.Rolls(auramsg, randomValue, auras)
countertext = 0
auraScrollSpeed = 0.3
ended = true
break
end
end
local tweenInfo2 = TweenInfo.new(0.25)
local tweenreturn0 = TweenService:Create(skipbutton, tweenInfo2, {Position = UDim2.new(0.346, 0, 1.5, 0)})
local tweenreturn1 = TweenService:Create(equipbutton, tweenInfo2, {Position = UDim2.new(0.546, 0, 1.5, 0)})
local function chouse()
equipbutton.Visible = true
skipbutton.Visible = true
tween0:Play()
tween1:Play()
end
local function evade()
gui.Transparency = 1
rollbutton.Visible = true
spinmsg.Visible = false
auramsg.Visible = false
spinscounter.Value = spinscounter.Value + 1
tweenreturn0:Play()
tweenreturn1:Play()
end
if ended then
valuesomelol = auramsg.ChanceForAura.OneInValue.Value
if tonumber(setting.Text) then
if setting.Text ~= 0 then
if valuesomelol <= textonein then
evade()
return
end
chouse()
end
else
chouse()
end
skipbutton.MouseButton1Click:Connect(function()
evade()
end)
equipbutton.MouseButton1Click:Connect(function()
evade()
guiplayer.Aura.Text = auramsg.Text
guiplayer.Chance.Text = auramsg.ChanceForAura.Text
guiplayer.Aura.TextColor3 = auramsg.TextColor3
curentaura.Value = auramsg.Text
end)
end
end)
quickdice.OnServerEvent:Connect(function(player, isquickdiceon)
print(player)
print(isquickdiceon)
if isquickdiceon == true then
player.Character:SetAttribute("QK", true)
else
player.Character:SetAttribute("QK", false)
end
end)
Error: ServerScriptService.Dices:99: attempt to compare number <= Instance
Also a profs about values changing:
local module = {}
function module.Rolls(auramsg, randomnumber, auras)
local selectedAura
for _, aura in pairs(auras) do
local auraProbability = 1 / aura.OneIn
if randomnumber <= auraProbability then
auramsg.Text = aura.name
auramsg.TextColor3 = aura.TextColor
auramsg.ChanceForAura.Text = "1 in " .. aura.OneIn
auramsg.ChanceForAura:WaitForChild("OneInValue").Value = aura.OneIn
print(auramsg.ChanceForAura:WaitForChild("OneInValue").Value)
if selectedAura == nil then
selectedAura = aura.name
end
break
else
randomnumber = randomnumber - auraProbability
end
end
wait(0.01)
end
return module