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: Chance.

Previous Thread :: Next Thread 
FearlessBiscuit is not online. FearlessBiscuit
Joined: 16 Jun 2013
Total Posts: 1157
14 Feb 2015 11:37 PM
How do i make an option for a chance like theres items and then it has a chance for different like the TF2 Crate System?



Such as

math.random(10)

if it ='s 2 it will be this... so?
Report Abuse
FearlessBiscuit is not online. FearlessBiscuit
Joined: 16 Jun 2013
Total Posts: 1157
14 Feb 2015 11:49 PM
Bump
Report Abuse
DigitalVeer is not online. DigitalVeer
Joined: 23 Jun 2009
Total Posts: 4182
14 Feb 2015 11:52 PM
Say you have a model called 'Crate'
Inside 'Crate', you have a folder named 'Items'

Say inside a script in a part in Crate, you have a script..


items = script.Parent.Parent["Items"]

function getRandomItem()
return items:GetChildren()[math.random(1,#items:GetChildren())]
end

print("The random item chosen is: " .. getRandomItem().Name .. "!")
Report Abuse
FearlessBiscuit is not online. FearlessBiscuit
Joined: 16 Jun 2013
Total Posts: 1157
14 Feb 2015 11:57 PM
Yeah what if it was a gui like this?'


Whole Script:

GUI = script.Parent
CD = script.Parent.Countdown
UN = script.Parent.uncrate
D = script.Parent.Inv

local player = game.Players.LocalPlayer

uncrate = false
local sound = Instance.new("Sound")
sound.SoundId = "http://www.roblox.com/asset/?id=216424346"
sound.Parent = player.Character.Torso


Countdown = true
CD.Visible = false
Item = script.Parent.Item
Item.Visible = false
IN = script.Parent.IN
IQ = script.Parent.IQ
-------------------------------- VARIABLES

function onClicked()
if uncrate == false then
CD.Visible = true
UN.Visible = false
CD.Text = "5"
sound:Play()
wait(1.2)
CD.Text = "4"
wait(1.1)
CD.Text = "3"
wait(1.1)
CD.Text = "2"
wait(1.1)
CD.Text = "1"
wait(0.3)
GUI.BackgroundTransparency = 1
Item.Visible = true
IN.Text = "Key"
IQ.Text = "Common"
CD.Visible = false
wait(3)
sound:Stop()
IN.Text = ""
IQ.Text = ""
Item.Visible = false
else
UN.Visible = true
GUI.BackgroundTransparency = 0.5
CD.Visible = false
Item.Visible = false
end
end


script.Parent.uncrate.MouseButton1Down:connect(onClicked)
Report Abuse
FearlessBiscuit is not online. FearlessBiscuit
Joined: 16 Jun 2013
Total Posts: 1157
15 Feb 2015 12:04 AM
NVM GOT IT THANK YOU SO MUCH DUDE

+1 Vouch
Report Abuse
FearlessBiscuit is not online. FearlessBiscuit
Joined: 16 Jun 2013
Total Posts: 1157
15 Feb 2015 12:10 AM
But there is one slight problem. it keeps selecting the same thing.
Report Abuse
3KlicksNorth is not online. 3KlicksNorth
Joined: 17 Jul 2013
Total Posts: 220
15 Feb 2015 12:17 AM
Are you making it use math.random() each time you click?
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