Ptwisted
|
  |
| Joined: 13 Feb 2013 |
| Total Posts: 568 |
|
|
| 03 Mar 2015 03:10 PM |
Okay, so I made a gui and when someone clicks it, it will insert a Special Mesh into all the LocalPlayer's parts, but I'm trying to figure out how to make it such that if the "NewMesh" already exists in the player the button won't insert another mesh. Help?
button = script.Parent
button.MouseButton1Click:connect(function(clicker) local bodyParts = game.Players.LocalPlayer.Character:GetChildren() for i,b in pairs (bodyParts) do if (b.className == "Part") then local newMesh = Instance.new("SpecialMesh", b) newMesh.Name = "NewMesh" b.BrickColor = BrickColor.new("Black") elseif (b.className == "Hat") then b:remove() elseif (b.className == "Shirt") then b:remove() elseif (b.className == "Pants") then b:remove() elseif (b.className == "ShirtGraphic") then b.Graphic = "" end end end)
function GetRidofOldMesh() local OldMesh = game.Players.LocalPlayer.Character.Head:FindFirstChild("NewMesh") local bodyParts = game.Players.LocalPlayer.Character:GetChildren() for i,b in pairs (bodyParts) do if OldMesh ~= nil then OldMesh:remove() print("Deleted mesh") end end end
button.MouseButton1Click:connect(GetRidofOldMesh) |
|
|
| Report Abuse |
|
|
|
| 03 Mar 2015 03:12 PM |
you add a debounce and remove old ones
also stop using destroy |
|
|
| Report Abuse |
|
|
|
| 03 Mar 2015 03:12 PM |
*stop using remove()
use destroy() |
|
|
| Report Abuse |
|
|
Ptwisted
|
  |
| Joined: 13 Feb 2013 |
| Total Posts: 568 |
|
|
| 03 Mar 2015 03:22 PM |
| How would I know which mesh to delete since the meshes have the same names? Ex. If two meshes are inserted into the character both named "NewMesh" how will the script know which mesh to delete? |
|
|
| Report Abuse |
|
|
|
| 03 Mar 2015 03:23 PM |
| change the name of the mesh when created to be named "Mesh_PlayerNameHere" |
|
|
| Report Abuse |
|
|
AnimeWiki
|
  |
| Joined: 26 Oct 2014 |
| Total Posts: 460 |
|
|
| 03 Mar 2015 03:25 PM |
a = {}
function createmesh(part) local mesh = Instance.new("SpecialMesh", part) table.insert(a,mesh) return mesh end
for k,v in pairs(a) do k,v = nil,nil end
|
|
|
| Report Abuse |
|
|