generic image
Processing...
  • Games
  • Catalog
  • Develop
  • Robux
  • Search in Players
  • Search in Games
  • Search in Catalog
  • Search in Groups
  • Search in Library
  • Log In
  • Sign Up
  • Games
  • Catalog
  • Develop
  • Robux
   
ROBLOX Forum » Game Creation and Development » Scripting Helpers
Home Search
 

How can I?

Previous Thread :: Next Thread 
Gladii is not online. Gladii
Joined: 10 Mar 2012
Total Posts: 1713
06 Sep 2014 02:11 PM
How can I make this script so when you buy the item your money cant go negative?
What it does is
Money : 100
Buys
money : 0
Buys
Money : -100

local a = 1000
local b = 100
local cba = math.random(1,400)
local abc = math.random(cba,400)
local acb = math.random(abc,400)
print(abc)
winAfterTurns = acb
textures = {"http://www.roblox.com/asset/?id=169795759",
"http://www.roblox.com/asset/?id=165024076",
"http://www.roblox.com/asset/?id=169795842",
"http://www.roblox.com/asset/?id=169795910",
"http://www.roblox.com/asset/?id=169795759"}


slots = {script.Parent.Parent.Slot1, script.Parent.Parent.Slot2, script.Parent.Parent.Slot3, script.Parent.Parent.Slot4, script.Parent.Parent.Slot5}
local forcewin = 1
debounce = false


for d = 1, 5 do
slots[d].Decal.Texture = textures[math.random(1, 5)]
end

function checkWin()
local same = 1
local winner = false
for d = 2, 4 do
if (slots[d].Decal.Texture == slots[1].Decal.Texture) then
same = same + 1
end
end
if (same == 4) then
winner = true
end
return winner
end

script.Parent.ClickDetector.MouseClick:connect(function()
if (debounce == false) then
debounce = true
game.Players.LocalPlayer.leaderstats.Units.Value = game.Players.LocalPlayer.leaderstats.Units.Value-b
b = b +20
a = a +240
for i = 1, 30 do
wait(i/100)
script.Parent.one:Play()
for d = 1, 5 do
slots[d].Decal.Texture = textures[math.random(1, 5)]
end
end
if (forcewin == winAfterTurns) then
local num = math.random(1, 5)
for d = 1, 5 do
slots[d].Decal.Texture = textures[num]
end
forcewin = 1
else
forcewin = forcewin + 1
end
if (checkWin()) then
game.Players.LocalPlayer.leaderstats.Units.Value = game.Players.LocalPlayer.leaderstats.Units.Value+a
a = a+50
end
debounce = false
end
end)

while true do
wait()
script.Parent.Parent.Button.SurfaceGui.TextLabel.Text = "Cost:" .. b .. " Jackpot:" .. a
end



Report Abuse
truman89 is not online. truman89
Joined: 18 May 2008
Total Posts: 531
06 Sep 2014 02:14 PM
Use the if-then conditional statement where if the money is less than 0, it won't work.


if money < 0 then

Like that
Report Abuse
Gladii is not online. Gladii
Joined: 10 Mar 2012
Total Posts: 1713
06 Sep 2014 02:17 PM
How do i get to the players money?
I know its something like game.Players.LocalPlayer.leaderstats.Units.Value
Report Abuse
truman89 is not online. truman89
Joined: 18 May 2008
Total Posts: 531
06 Sep 2014 02:20 PM
I can't tell you that. I'd need more information on the script.
Report Abuse
Gladii is not online. Gladii
Joined: 10 Mar 2012
Total Posts: 1713
06 Sep 2014 02:29 PM
It's a slot machign script press a button,
random chance of winning.
Report Abuse
Previous Thread :: Next Thread 
Page 1 of 1
 
 
ROBLOX Forum » Game Creation and Development » Scripting Helpers
   
 
   
  • About Us
  • Jobs
  • Blog
  • Parents
  • Help
  • Terms
  • Privacy

©2017 Roblox Corporation. Roblox, the Roblox logo, Robux, Bloxy, and Powering Imagination are among our registered and unregistered trademarks in the U.S. and other countries.



Progress
Starting Roblox...
Connecting to Players...
R R

Roblox is now loading. Get ready to play!

R R

You're moments away from getting into the game!

Click here for help

Check Remember my choice and click Launch Application in the dialog box above to join games faster in the future!

Gameplay sponsored by:
Loading 0% - Starting game...
Get more with Builders Club! Join Builders Club
Choose Your Avatar
I have an account
generic image