Hello there,
im making a flip system.
How does it work?
U basically input a number and then u press flip. You have a 50/50 chance of winning.
If you win u get double amount and if u lose u lose the amount.
When making and testing, i got this error: Attempt to compare nil <= number Line 87 ServerScriptService: Script
This is my Code:
----------------------------------------------------------------------------------- FLIP GAME
game.ReplicatedStorage.GameEvents.FlipEvent.OnServerEvent:Connect(function(player)
local num = tonumber(player.PlayerGui.MainUI.FlipGame.DecorationI.TextBox)
if player.leaderstats.MetaBucks.Value >=num then
local Trigger = script.Parent -- The Trigger
-- localFUNCTION
-- Function
-- when Triggered function
player.leaderstats.MetaBucks.Value = player.leaderstats.MetaBucks.Value -num
local Chance = math.random(1,100)
local function win()
player.leaderstats.MetaBucks.Value = num *2
player.PlayerGui.MainUI.FlipGame.DecorationI.wintxt.TextColor3 = Color3.fromRGB(92, 163, 255)
wait(1)
player.PlayerGui.MainUI.FlipGame.DecorationI.wintxt.TextColor3 = Color3.fromRGB(43, 47, 72)
player.PlayerGui.MainUI.FlipGame.DecorationI.Status.Text = ("You won and you got "..num *2 .."!")
wait(2)
player.PlayerGui.MainUI.FlipGame.DecorationI.Status.Text = ("Press FLIP to flip")
end
local function lose()
player.PlayerGui.MainUI.FlipGame.DecorationI.l.TextColor3 = Color3.fromRGB(92, 163, 255)
wait(1)
player.PlayerGui.MainUI.FlipGame.DecorationI.l.TextColor3 = Color3.fromRGB(43, 47, 72)
player.PlayerGui.MainUI.FlipGame.DecorationI.Status.Text = ("You sadly lost, try again!")
wait(2)
player.PlayerGui.MainUI.FlipGame.DecorationI.Status.Text = ("Press FLIP to flip")
end
if Chance <= 55 then -- if the answer is 55 or under you will lose
lose()
elseif Chance <= 50 then -- if the answer is 55 or under you will win
win()
end
end
end)
----------------------------------------------------------------------------------------------------
I would really appreciate it when you could help!
Thank you and have a nice day!