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
 

I need help with a random tool giver

Previous Thread :: Next Thread 
cheeseman50166 is not online. cheeseman50166
Joined: 24 Jan 2015
Total Posts: 40
08 May 2017 06:16 PM
So I need help with a random tool giver script, so when you spawn it grabs any weapons from server storage or etc, and puts it into your backpack.
Report Abuse
ExpensiveGaming is not online. ExpensiveGaming
Joined: 01 Apr 2013
Total Posts: 783
08 May 2017 06:16 PM
You could use math.random
Report Abuse
cheeseman50166 is not online. cheeseman50166
Joined: 24 Jan 2015
Total Posts: 40
08 May 2017 06:24 PM
I already tried

Report Abuse
ExpensiveGaming is not online. ExpensiveGaming
Joined: 01 Apr 2013
Total Posts: 783
08 May 2017 06:24 PM
Send your script
Report Abuse
Exeplex is not online. Exeplex
Joined: 29 May 2008
Total Posts: 1081
08 May 2017 06:27 PM
local Tools = {};

for i,t in pairs(Location:GetChildren()) do
if (t:IsA("Tool")) then -- Check if it's a tool
table.insert(Tools, t); -- Add it in the table!
end
end

local Tool = Tools[math.random(1, #Tools)]; -- Pick a random one out of the table!
Report Abuse
Exeplex is not online. Exeplex
Joined: 29 May 2008
Total Posts: 1081
08 May 2017 06:31 PM
Of course, change the "Location" part. Or, even better, make it a variable in case you ever change the location!
Report Abuse
cheeseman50166 is not online. cheeseman50166
Joined: 24 Jan 2015
Total Posts: 40
08 May 2017 07:18 PM
Here is the script. Anything wrong with it?

local Earth = game.Lighting.Earth
local Fire = game.Lighting.Fire
while true do
wait(1)
Magic = math.random(1.2)
if Magic == 1 then
Earth:Clone()
Earth.Parent = game.Players.Backpack
if Magic == 2 then
Fire:Clone()
Fire.Parent = game.Workspace.Players.Backpack
end

end
end
Report Abuse
Wunder_Wulfe is online. Wunder_Wulfe
Joined: 13 Sep 2016
Total Posts: 8356
08 May 2017 07:19 PM
u dont understand how if statements work

a number cant be 1 and 2 at the same time (it doesnt change)
Report Abuse
Exeplex is not online. Exeplex
Joined: 29 May 2008
Total Posts: 1081
08 May 2017 07:50 PM
math.random() works by putting a minimum and maximum value.
Example: math.random(3, 9);

It will pick randomly from 3 to 9.

--

Create a GameTools Folder in lighting and place your Earth and Fire inside of it.
(You can re-name it later)

local Tools = {};

for i,t in pairs(GameTools:GetChildren()) do
if (t:IsA("Tool")) then -- Check if it's a tool
table.insert(Tools, t); -- Add it in the table!
end
end

local Tool = Tools[math.random(1, #Tools)]; -- Pick a random one out of the table!
Report Abuse
cheeseman50166 is not online. cheeseman50166
Joined: 24 Jan 2015
Total Posts: 40
08 May 2017 08:26 PM
sorry for giving you guys all this trouble. I am only a beginner at scripting
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