|
| 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 |
|
|
| |
|
|
| 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 |
|
|
|
| 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 |
|
|
|
| 15 Feb 2015 12:04 AM |
NVM GOT IT THANK YOU SO MUCH DUDE
+1 Vouch |
|
|
| Report Abuse |
|
|
|
| 15 Feb 2015 12:10 AM |
But there is one slight problem. it keeps selecting the same thing.
|
|
|
| Report Abuse |
|
|
|
| 15 Feb 2015 12:17 AM |
| Are you making it use math.random() each time you click? |
|
|
| Report Abuse |
|
|