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: Clone Weapons from Lightning - simple script

Previous Thread :: Next Thread 
dmjoe is not online. dmjoe
Joined: 01 May 2009
Total Posts: 2387
11 Jul 2011 09:23 AM
I know how to clone weapons from the lighting and put them back into the workspace, but how would I put them in RANDOM locations on my map


I have a bunch of weapons that i want to appear randomly (time and location) but i am terrible when it comes to math.random

I cant understand how to do this, can anyone help?
Report Abuse
dmjoe is not online. dmjoe
Joined: 01 May 2009
Total Posts: 2387
11 Jul 2011 09:26 AM
bump
Report Abuse
nightmare3o is not online. nightmare3o
Joined: 21 Jun 2008
Total Posts: 956
11 Jul 2011 09:26 AM
Math.random?
Report Abuse
dmjoe is not online. dmjoe
Joined: 01 May 2009
Total Posts: 2387
11 Jul 2011 09:29 AM
yeah, thats what randomises a script
Report Abuse
nightmare3o is not online. nightmare3o
Joined: 21 Jun 2008
Total Posts: 956
11 Jul 2011 09:30 AM
Yeah use it so it randomizes the weapons.
Try It
Report Abuse
EpicDucks is not online. EpicDucks
Joined: 28 Apr 2009
Total Posts: 2015
11 Jul 2011 09:30 AM
use this: math.random(1, 3000)

It will use any number from 1- 3000

Now you can use this in your script, I won't build it for you though.

It doesn't have to be 1- 3000, it can be 1- 451 if you change it to be or 254- 281

math.random(254, 281)

Like that.
Report Abuse
dmjoe is not online. dmjoe
Joined: 01 May 2009
Total Posts: 2387
11 Jul 2011 09:31 AM
my point is, i dont understand how to clone the weopne and put it at a random time and location
Report Abuse
EpicDucks is not online. EpicDucks
Joined: 28 Apr 2009
Total Posts: 2015
11 Jul 2011 09:31 AM
It picks a random number and you can use it in your script.
Report Abuse
dmjoe is not online. dmjoe
Joined: 01 May 2009
Total Posts: 2387
11 Jul 2011 09:35 AM
yes, but i dont know how to put it together in a script or how to clone from the lightning
Report Abuse
darkkiller5555 is not online. darkkiller5555
Joined: 22 Nov 2009
Total Posts: 6359
11 Jul 2011 09:36 AM
weapon.Handle.CFrame = CFrame.new(math.random(1,100), math.random(1,100), math.random(1,100))
Report Abuse
1Ra is not online. 1Ra
Joined: 02 May 2010
Total Posts: 2400
11 Jul 2011 09:37 AM
gun = game.Lighting:clone()
gun.Parent = game.Workspace
gun.Position = Vector3.new(math.random,math.random,math.random)
Report Abuse
dmjoe is not online. dmjoe
Joined: 01 May 2009
Total Posts: 2387
11 Jul 2011 09:41 AM
thankyou, but where would i put the wepon name, it looks as if it is just cloning the lighting
Report Abuse
dmjoe is not online. dmjoe
Joined: 01 May 2009
Total Posts: 2387
11 Jul 2011 09:46 AM
also, there is alot of wpeopns that I want to use, is there a way to pick a random one of the weapons and put it in a random place on my map in random intervals so that I dont have to have a script for each?
Report Abuse
dmjoe is not online. dmjoe
Joined: 01 May 2009
Total Posts: 2387
11 Jul 2011 09:53 AM
bump?
Report Abuse
yacker3000 is not online. yacker3000
Joined: 22 Nov 2008
Total Posts: 259
11 Jul 2011 10:08 AM
There sure is a way. However, due to you being the scripter, we can't and shouldn't do everything for you. I'll give you a basic, step by step pseudo code, then you'll have to do all the Lua stuff.

First, to choose a random weapon to spawn:
Place all weapons under the same model in lighting. Place nothing else in this model.
Write a function inside the spawn script that assigns all the contents of the weapon model into a list. To do this, use weapon_list = Lighting.Wep_model:GetChildren()

Then, open a forever loop that waits for a random amount of time for each iteration. After the wait, choose a random gun from the weapon_list. If you're not sure how to do this, ask.

After that, position the gun using dark or 1ra's script.
Report Abuse
dmjoe is not online. dmjoe
Joined: 01 May 2009
Total Posts: 2387
11 Jul 2011 10:14 AM
hmm, thx, ill work on this
Report Abuse
dmjoe is not online. dmjoe
Joined: 01 May 2009
Total Posts: 2387
11 Jul 2011 10:15 AM
actually, im not sure how to do this... so im asking XD
Report Abuse
dmjoe is not online. dmjoe
Joined: 01 May 2009
Total Posts: 2387
11 Jul 2011 10:24 AM
im also confuese about the 'choose a randome weapon to spawn' but
Report Abuse
yacker3000 is not online. yacker3000
Joined: 22 Nov 2008
Total Posts: 259
11 Jul 2011 10:25 AM
What aren't you sure of? the lists? The randomizing? All of it? I'll be more specific if that's what you want. However, I'm not willing to hand you a script this big. That would not help you learn, therefore, it would be counter-productive. Sorry.
Report Abuse
dmjoe is not online. dmjoe
Joined: 01 May 2009
Total Posts: 2387
11 Jul 2011 10:26 AM
of course, i would prefer learn


i am confused with 'choose a random weapon to spawn' i dont know how how to create that bit of the script
Report Abuse
yacker3000 is not online. yacker3000
Joined: 22 Nov 2008
Total Posts: 259
11 Jul 2011 10:30 AM
k, here's how I'd choose a random wep:

You have a list containing all the weps you've created. This list is made up of links to the actual weapon objects. To get a link out of the list, all you need to do is tell it which "index" you want to read:

current_wep = wep_list[1]

That will give you the first weapon in the list. To change what weapon you're pulling out, simply put a different number inside the []. To get a random weapon from the table, just plug in a random index, like this:

current_wep = wep_list[math.random(1, #wep_list)]
Report Abuse
dmjoe is not online. dmjoe
Joined: 01 May 2009
Total Posts: 2387
11 Jul 2011 10:31 AM
ok, i c
Report Abuse
dmjoe is not online. dmjoe
Joined: 01 May 2009
Total Posts: 2387
11 Jul 2011 10:33 AM
so this is what I would do...

current_wep = wep_list[math.random(1, #wep_list)]

while true do
wait (ammount of time)

and then....
Report Abuse
dmjoe is not online. dmjoe
Joined: 01 May 2009
Total Posts: 2387
11 Jul 2011 10:34 AM
no... wait [math.Random(1-60)]


or something like that
Report Abuse
dmjoe is not online. dmjoe
Joined: 01 May 2009
Total Posts: 2387
11 Jul 2011 10:41 AM
right?
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