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 do I get the chance something is going to happen

Previous Thread :: Next Thread 
LordMatthewII is not online. LordMatthewII
Joined: 20 Aug 2011
Total Posts: 10873
19 Jun 2014 10:14 PM
I want to do with mathematically.


table={1,2,3,3,3,4,5,6}
ChanceThreeIsPicked=what?
print(ChanceThreeIsPicked)

local num=table[math.random(#table)]
Report Abuse
LordMatthewII is not online. LordMatthewII
Joined: 20 Aug 2011
Total Posts: 10873
19 Jun 2014 10:16 PM
?
Report Abuse
TheNewScripter is not online. TheNewScripter
Joined: 02 Mar 2010
Total Posts: 2432
19 Jun 2014 10:19 PM
    local possibilities = { 1, 2, 3, 3, 3, 4, 5, 6 }
    
    function oddsForValue(value)
        local total = 0
        for _, val in pairs(possibilities) do
            if value == val then
                total = total + 1
            end
        end
        return total / #possibilities
    end
    
    print(possibilities(3)) --> 3/8th or 0.375 or 37.5%
Report Abuse
TheNewScripter is not online. TheNewScripter
Joined: 02 Mar 2010
Total Posts: 2432
19 Jun 2014 10:21 PM
That's assuming that every value has an equal chance to be picked. If you're using math.random(), then this is true.
Report Abuse
Forlapse is not online. Forlapse
Joined: 07 Jan 2014
Total Posts: 122
19 Jun 2014 10:21 PM
For that you need a good understanding of function dumps, and I would probably just make that a string, not a table.

http://wiki.roblox.com/index.php?title=Function_Dump/String_Manipulation
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