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: Tool help

Previous Thread :: Next Thread 
ArceusLevelX is not online. ArceusLevelX
Joined: 16 Apr 2013
Total Posts: 762
24 Apr 2013 08:10 PM
How do I randomize which egg comes out of the gun? I have FakeWaterFaberge, FakeStoneFaberge and FakeRainbowFaberge all in lighting.

local Mouse = game.Players.LocalPlayer:GetMouse()

function keyPressed(key)
key = key:lower()
if key == "y" then
co = game.Lighting.StoneFaberge:clone()
co.Parent = game.Workspace
co.Handle.Position = script.Parent.Handle.Position
co.Handle.Velocity = Vector3.new(10,10,10)
wait(2)
co.Handle.Velocity = Vector3.new(0,0,0)

elseif key == "z" then
co = game.Lighting.WaterFaberge:clone()
co.Parent = game.Workspace
co.Handle.Position = script.Parent.Handle.Position
co.Handle.Velocity = Vector3.new(10,10,10)
wait(2)
co.Handle.Velocity = Vector3.new(0,0,0)

elseif key == "x" then
co = game.Lighting.RainbowFaberge:clone()
co.Parent = game.Workspace
co.Handle.Position = script.Parent.Handle.Position
co.Handle.Velocity = Vector3.new(10,10,10)
wait(2)
co.Handle.Velocity = Vector3.new(0,0,0)

end
end

Mouse.KeyDown:connect(keyPressed)
Report Abuse
ArceusLevelX is not online. ArceusLevelX
Joined: 16 Apr 2013
Total Posts: 762
24 Apr 2013 08:15 PM
Bump.
Report Abuse
ArceusLevelX is not online. ArceusLevelX
Joined: 16 Apr 2013
Total Posts: 762
24 Apr 2013 08:23 PM
Bump.
Report Abuse
BJCarpenter is online. BJCarpenter
Joined: 04 Nov 2008
Total Posts: 4416
24 Apr 2013 08:24 PM
(Will contain Errors)

function keyPressed(key)
key = key:lower()
if key == "y" then

local R = math.random()

if R < .3 then
co = game.Lighting.StoneFaberge:clone()
elseif R < .6 then

co = game.Lighting.WaterFaberge:clone()
else
co = game.Lighting.RainbowFaberge:clone()
end -- R?

co.Parent = game.Workspace
co.Handle.Position = script.Parent.Handle.Position
co.Handle.Velocity = Vector3.new(10,10,10)
wait(2)
co.Handle.Velocity = Vector3.new(0,0,0)

end -- y?

end -- func

Report Abuse
ForceSky is not online. ForceSky
Joined: 30 Jul 2012
Total Posts: 2379
24 Apr 2013 08:26 PM
Use a table.

local eggammo = {"Egg1"; "Egg2", "Egg3"}

local choice = script.Parent:FindFirstChild(eggammo[math.random(1, #eggammo)]

This would be inside the tool and the eggs would also be.
Report Abuse
ArceusLevelX is not online. ArceusLevelX
Joined: 16 Apr 2013
Total Posts: 762
24 Apr 2013 08:30 PM
So something like this?

function keyPressed(key)
key = key:lower()
if key == "y" then
local eggammo = {"Egg1"; "Egg2"}
local choice = script.Parent:FindFirstChild(eggammo[math.random(1, #eggammo)]

co = eggammo:clone()
eggammo.Parent = game.Workspace
eggammo.Handle.Position = script.Parent.Handle.Position
eggammo.Handle.Velocity = Vector3.new(10,10,10)
wait(2)
eggammo.Handle.Velocity = Vector3.new(0,0,0)
end
Report Abuse
ArceusLevelX is not online. ArceusLevelX
Joined: 16 Apr 2013
Total Posts: 762
24 Apr 2013 08:34 PM
undefinedBump.
Report Abuse
chris1989 is not online. chris1989
Joined: 30 Nov 2007
Total Posts: 2520
24 Apr 2013 08:42 PM
local Mouse = game.Players.LocalPlayer:GetMouse()
local Eggs = {game.Lighting.StoneFaberge:clone(), game.Lighting.WaterFaberge:clone(), game.Lighting.RainbowFaberge:clone()}

function keyPressed(key)
local key = key:lower()
if key == "y" then
local co = Eggs[math.random(1,#Eggs)]:clone()
co.Parent = game.Workspace
co.Handle.Position = script.Parent.Handle.Position
co.Handle.Velocity = Vector3.new(10,10,10)
wait(2)
co.Handle.Velocity = Vector3.new(0,0,0)
end
end

Mouse.KeyDown:connect(keyPressed)
Report Abuse
ArceusLevelX is not online. ArceusLevelX
Joined: 16 Apr 2013
Total Posts: 762
24 Apr 2013 08:55 PM
With that script I can use the tool without it being equipped.
Report Abuse
noone334 is not online. noone334
Joined: 02 Aug 2011
Total Posts: 2454
24 Apr 2013 09:14 PM
Maybe try having a BoolValue?
Report Abuse
ArceusLevelX is not online. ArceusLevelX
Joined: 16 Apr 2013
Total Posts: 762
24 Apr 2013 09:26 PM
Bump.
Report Abuse
chris1989 is not online. chris1989
Joined: 30 Nov 2007
Total Posts: 2520
24 Apr 2013 09:29 PM
local Eggs = {game.Lighting.StoneFaberge:clone(), game.Lighting.WaterFaberge:clone(), game.Lighting.RainbowFaberge:clone()}

function keyPressed(key)
local key = key:lower()
if key == "y" then
local co = Eggs[math.random(1,#Eggs)]:clone()
co.Parent = game.Workspace
co.Handle.Position = script.Parent.Handle.Position
co.Handle.Velocity = Vector3.new(10,10,10)
wait(2)
co.Handle.Velocity = Vector3.new(0,0,0)
end
end

script.Parent.Equipped:connect(function(Mouse)
Mouse.KeyDown:connect(keyPressed)
emd)
Report Abuse
BJCarpenter is online. BJCarpenter
Joined: 04 Nov 2008
Total Posts: 4416
25 Apr 2013 12:52 AM
ArceusLevelX,

Why would u bump this?

I gave u the function.... What do u want, Dancing Girls, too....?

--Bri
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