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