|
| 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 |
|
|
| |
|
| |
|
|
| 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
|
  |
| 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 |
|
|
|
| 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 |
|
|
| |
|
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 |
|
|
|
| 24 Apr 2013 08:55 PM |
| With that script I can use the tool without it being equipped. |
|
|
| Report Abuse |
|
|
noone334
|
  |
| Joined: 02 Aug 2011 |
| Total Posts: 2454 |
|
|
| 24 Apr 2013 09:14 PM |
| Maybe try having a BoolValue? |
|
|
| Report Abuse |
|
|
| |
|
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 |
|
|
|
| 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 |
|
|