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
 

Re: Why doesnt this script work?

Previous Thread :: Next Thread 
BirdBoy146 is not online. BirdBoy146
Joined: 25 Sep 2011
Total Posts: 39
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 is not online. 12packkid
Joined: 24 Jun 2011
Total Posts: 1418
02 Sep 2014 12:55 PM
bindablefunction.

no questions.
k.
Report Abuse
BirdBoy146 is not online. BirdBoy146
Joined: 25 Sep 2011
Total Posts: 39
02 Sep 2014 01:29 PM
Well I dont understand bindable functions so how can I use this on the script?
Report Abuse
BirdBoy146 is not online. BirdBoy146
Joined: 25 Sep 2011
Total Posts: 39
02 Sep 2014 01:39 PM
Well I dont understand bindable functions so how can I use this on the script?
Report Abuse
BirdBoy146 is not online. BirdBoy146
Joined: 25 Sep 2011
Total Posts: 39
02 Sep 2014 02:07 PM
Bumb
Report Abuse
BirdBoy146 is not online. BirdBoy146
Joined: 25 Sep 2011
Total Posts: 39
03 Sep 2014 10:04 AM
Anyone?
Report Abuse
getkoed is not online. 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
BirdBoy146 is not online. BirdBoy146
Joined: 25 Sep 2011
Total Posts: 39
03 Sep 2014 10:35 AM
It worked thank you very much!
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