|
| 02 Sep 2014 12:54 PM |
function getNum() local num = math.random(1,4) print("Random Number chosen.") end
getNum() if num == 1 then local map1 = script.Parent.Parent.Lighting.Map1 local clone = map1:Clone() clone.Parent = Workspace print("map1 chosen") wait(5) clone:Destroy() elseif num == 2 then
local map2 = script.Parent.Parent.Lighting.Map2 local clone = map2:Clone() clone.Parent = Workspace print("map2 chosen") wait(5) clone:Destroy() elseif num == 3 then local map3 = script.Parent.Parent.Lighting.Map3 local clone = map3:Clone() clone.Parent = Workspace print("map3 chosen") wait(5) clone:Destroy() elseif num == 4 then
local map4 = script.Parent.Parent.Lighting.Map4 local clone = map4:Clone() clone.Parent = Workspace print("map4 chosen") wait(5) clone:Destroy() end
Well the weird thing is if I make the getNum like this it would work:
local num = math.random(1,4) print("Random Number chosen.")
if num == 1 then local map1 = script.Parent.Parent.Lighting.Map1 local clone = map1:Clone() clone.Parent = Workspace print("map1 chosen") wait(5) clone:Destroy() elseif num == 2 then
local map2 = script.Parent.Parent.Lighting.Map2 local clone = map2:Clone() clone.Parent = Workspace print("map2 chosen") wait(5) clone:Destroy() elseif num == 3 then local map3 = script.Parent.Parent.Lighting.Map3 local clone = map3:Clone() clone.Parent = Workspace print("map3 chosen") wait(5) clone:Destroy() elseif num == 4 then
local map4 = script.Parent.Parent.Lighting.Map4 local clone = map4:Clone() clone.Parent = Workspace print("map4 chosen") wait(5) clone:Destroy() end
But I really want this too be a function so how do I do this?
|
|
|
| Report Abuse |
|
|
12packkid
|
  |
| Joined: 24 Jun 2011 |
| Total Posts: 1418 |
|
|
| 02 Sep 2014 12:55 PM |
bindablefunction.
no questions. k. |
|
|
| Report Abuse |
|
|
|
| 02 Sep 2014 01:29 PM |
| Well I dont understand bindable functions so how can I use this on the script? |
|
|
| Report Abuse |
|
|
|
| 02 Sep 2014 01:39 PM |
| Well I dont understand bindable functions so how can I use this on the script? |
|
|
| Report Abuse |
|
|
| |
|
| |
|
getkoed
|
  |
| Joined: 18 Feb 2010 |
| Total Posts: 2298 |
|
|
| 03 Sep 2014 10:05 AM |
function getNum() print("Random Number chosen.") return math.random(1, 4) end
local num = getNum()
-- the rest here |
|
|
| Report Abuse |
|
|
|
| 03 Sep 2014 10:35 AM |
| It worked thank you very much! |
|
|
| Report Abuse |
|
|