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 finding the most recently cloned object.

Previous Thread :: Next Thread 
Myzta is not online. Myzta
Joined: 20 Nov 2011
Total Posts: 170
29 Aug 2015 03:02 PM
If I were to write a script like this:

Plus.MouseButton1Down:connect(function()
Number.Value = Number.Value + 1
People.Text = Number.Value
local p = Player:clone()
p.Name = p.Name .. Number.Value
p.Parent = ListOfPlayers
Minus.MouseButton1Down:connect(function()
Number.Value = Number.Value - 1
People.Text = Number.Value

end)

end)

How would I remove the most recently cloned object..?

ps (idk if this will help, but..) When it is cloned it adds a number based on the NumberValue, for example: Player1, Player2, Player3 ect

Hope you can help! Thanks
Report Abuse
direMitten is not online. direMitten
Joined: 18 Jun 2015
Total Posts: 1294
29 Aug 2015 03:55 PM
Every time an object is cloned, do

_G.latestClonedObject = -- the cloned object

To destroy it, do
_G.latestClonedObject


Alternatively, do
_G.clonedObjects = {}

and then every time an object is cloned do
table.insert(_G.clonedObjects, --the cloned object)

To destroy the latest cloned object, do
local item = _G.clonedObjects[#_G.clonedObjects]
table.remove(_G.clonedObjects[#_G.clonedObjcets]
item:Destroy()
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