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 » Scripters
Home Search
 

Re: attempt to compare boolean with number

Previous Thread :: Next Thread 
Edslaw is not online. Edslaw
Joined: 03 Nov 2008
Total Posts: 145
08 Jul 2017 08:05 PM
math.randomseed(tick()) for i = 1,3 do hack = (math.random(100)) print (hack) if 95 <= hack <= 100 then print "rare item won!" elseif 25 <= hack <= ## ################# ##### ####### item won" elseif 15 <= hack <= 24 then print "semi-rare item won" elseif hack < 14 then -- ## ###### range print "uncommon item won!" end end _________________________________________________________ i want it to generate a number then print something depending on what range its in but it keeps thinking its a boolean.. please help
Report Abuse
Edslaw is not online. Edslaw
Joined: 03 Nov 2008
Total Posts: 145
08 Jul 2017 08:07 PM
ok its not readable but remove the for i = 1,3
Report Abuse
Edslaw is not online. Edslaw
Joined: 03 Nov 2008
Total Posts: 145
08 Jul 2017 08:08 PM
nvm im an idiot
Report Abuse
masterblokz is not online. masterblokz
Joined: 17 Nov 2010
Total Posts: 9517
08 Jul 2017 08:09 PM
dunoo what half of that says but here's an example


hack = math.random(1,100)


if hack >= 80 then
print'>= 80'
elseif hack >= 60 then
print'>= 60"
end

try to adjust accordingly i guess
Report Abuse
Edslaw is not online. Edslaw
Joined: 03 Nov 2008
Total Posts: 145
08 Jul 2017 08:11 PM
yeah i realized that
Report Abuse
Edslaw is not online. Edslaw
Joined: 03 Nov 2008
Total Posts: 145
08 Jul 2017 08:15 PM
great now it keeps doing the same value over and over again
Report Abuse
masterblokz is not online. masterblokz
Joined: 17 Nov 2010
Total Posts: 9517
08 Jul 2017 08:39 PM
can ya post your whole code here
Report Abuse
masterblokz is not online. masterblokz
Joined: 17 Nov 2010
Total Posts: 9517
08 Jul 2017 08:40 PM
try this

for i = 1,3,1 do math.randomseed(tick()) hack = math.random(0,100) ---- stuff ---- wait() end
Report Abuse
Edslaw is not online. Edslaw
Joined: 03 Nov 2008
Total Posts: 145
08 Jul 2017 08:44 PM
heres a pastebin

/7KupPnas


now im getting


21:42:53.386 - Workspace.Script:48: 'end' expected (to close 'for' at line 1) near eof
Report Abuse
nullfeels is not online. nullfeels
Joined: 31 Mar 2017
Total Posts: 1215
08 Jul 2017 08:52 PM
Move math.randomseed(tick() outside the loop. You only need to call it once at the start of the script. Also, it's missing a closing parenthesis. "math.randomseed(tick())".

And again here: "hack = (math.random(0,100)" remove that starting parenthesis "hack = math.random(0,100)".

Finally you're missing an "end" at the end of your long if/elseif statement.
Report Abuse
Edslaw is not online. Edslaw
Joined: 03 Nov 2008
Total Posts: 145
08 Jul 2017 08:58 PM
i just destroyed the script lol now its even more messed up
Report Abuse
masterblokz is not online. masterblokz
Joined: 17 Nov 2010
Total Posts: 9517
09 Jul 2017 09:35 AM

math.randomseed(tick()) -- randomize
for i = 1,3 do -- after a function type thing, tab out everything in it to keep organization better
hack = math.random(0,100) -- random num between 0,100
print(hack.." HACK") -- shows what hack is
if hack <= 10 then -- if hack is LESS THAN or EQUAL TO 10 then print ' rare item '
print "rare item"
elseif hack <= 20 then
print "common item"
elseif hack <= 30 then
print "common item"
elseif hack <= 40 then pr#####c#######tem"
elseif hack <= 50 then
print "unccommon item"
elseif hack <= 60 then
print "uncommon item"

elseif hack <= 70 then
print "uncommon item"
elseif hack <= 80 then
print "semi-rare item"
elseif hack <= 90 then
print "semi-rare item"
elseif hack <= 100 then
print "extremely rare item" wait(1) -- wait 1 se######e#######a####o#####ut this wait at the top if you want it to wait 1 second before the first loop

end
end
^^^^^
I put that together with some tips and explanations, but just saying, it looks like the way you're doing the <='s is messed up. you might want to try doing this:


math.randomseed(tick()) -- randomize
for i = 1,3 do -- after a function type thing, tab out everything in it to keep organization better
hack = math.random(0,100) -- random num between 0,100
print(hack.." HACK") -- shows what hack is if hack >= 50 then -- if hack is MORE THAN OR EQUAL TO 50##h####r##### #o######tem'
print"really common item"
elseif hack >= 20 then
print'uncommon item'
elseif hack >= 0 then
print'rarest item'
wait(1) -- wait 1 se######e#######a####o#####ut this wait at the top if you want it to wait 1 second before the first loop

end
end

that way if hack is either 50 or anything between 50-100 then it's the common item, so basically 50 numbers worth of rarity if that makes sense, then if hack is 20 or 20-49 it's a rare item, 29 numbers worth of rarity, and then if hack>= 0 gives hack 20 numbers of rarity, you can adjust accordingly
Report Abuse
JarodOfOrbiter is not online. JarodOfOrbiter
Joined: 17 Feb 2011
Total Posts: 20029
09 Jul 2017 10:25 AM
Here's your solution, I apologise on their behalf.

95 <= hack <= 100

That will only work as
95 <= hack and hack <= 100

Change anything similar to the solution I provided and you should be good to go.


Report Abuse
masterblokz is not online. masterblokz
Joined: 17 Nov 2010
Total Posts: 9517
09 Jul 2017 10:51 AM
wow i totally skipped over that, i kinda didn't bother reading most of it due to the hashtags and formatting. i did provide some workin stuff in my last post tho ^_^
Report Abuse
Previous Thread :: Next Thread 
Page 1 of 1
 
 
ROBLOX Forum » Game Creation and Development » Scripters
   
 
   
  • 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