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: How would i make it so..

Previous Thread :: Next Thread 
robotmega is not online. robotmega
Joined: 16 May 2009
Total Posts: 14084
23 Jul 2012 11:07 PM
this removes 3 hats of the 6 i have in Lighting?

Will this work?

local cx = game.Lighting:GetChildren()
for i=1,#cx do
if cx[i].className == "Hat" then
cx[i]:clone().Parent = Fusion
end
end
wait()
if Fusion.Hat1 then
Fusion.Hat1:remove()
end
if Fusion.Hat2 then
Fusion.Hat2:remove()
end
if Fusion.Hat2 then
Fusion.Hat2:remove()
end
Report Abuse
robotmega is not online. robotmega
Joined: 16 May 2009
Total Posts: 14084
23 Jul 2012 11:19 PM
Will this work?

local cx = game.Lighting:GetChildren()
for i=1,#cx do
if cx[i].className == "Hat" then
cx[i]:clone().Parent = Fusion
end
end
wait()
local cxx = game.Lighting:GetChildren()
for i=1,#cxx do
if cxx[i].className == "Hat" then
local cxx2 = cxx[math.random(1,#cxx)]
cxx2[i]:remove()
end
end
Report Abuse
L2000 is not online. L2000
Joined: 03 Apr 2008
Total Posts: 77448
23 Jul 2012 11:20 PM
That doesn't appear as if it will work, as you would always remove "Hat1" and "Hat2" (If you wanted it to be random). I'd suggest something like this:

local hats = game.Lighting:GetChildren()

for i = 1,3 do -- For three hats
local hat = hats[math.random(1, #hats)] -- Get a random hat
hat:Destroy() -- Remove the hat
end

-- That will leave three hats in game.Lighting.
-- If you want it in a certain model, clone them first, then
-- Make 'hats' the clones instead of them in Lighting.
Report Abuse
robotmega is not online. robotmega
Joined: 16 May 2009
Total Posts: 14084
23 Jul 2012 11:29 PM
local hats = game.Lighting:GetChildren()
for i=1,#hats do
if hats[i].className == "Hat" then
local hat = hats[math.random(2, 3)] -- Get a random hat
hat[i]:clone().Parent = Fusion
end
end

I just made up that, which is better
Report Abuse
miz656 is not online. miz656
Joined: 19 Jul 2010
Total Posts: 15336
23 Jul 2012 11:31 PM
^

You never defined Fusion.

You say

math.random(2,3)

Which means, it wil only take hat 2 or hat 3. Never hat one.

Report Abuse
robotmega is not online. robotmega
Joined: 16 May 2009
Total Posts: 14084
23 Jul 2012 11:34 PM
@miz
My point is to get all the hats in Fusion.
Then delete 3 or 4.

But i made a diff one that just gives 2 or 3.
Report Abuse
Cheater is not online. Cheater
Joined: 29 Jun 2007
Total Posts: 5258
24 Jul 2012 02:23 AM
local cx = game.Lighting:GetChildren()
for i=1,#cx do
if cx[i].className == "Hat" then
Fusion = cx[i]:clone().Parent
end
end
hats = Fusion:GetChildren()
l = #Fusion
for h = 1, 3 do
x = math.random(1, l)
hats[x]:Destroy()
end

Not sure if that will even work but I tried something.
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