I am making a GUI that's supposed to remove a Model when you click on it. It doesn't work right now, and another problem is I want it just to remove ONE Model when you click on it, not the whole set. (It's a Gui that's supposed to remove a Chair in the game. I have about 30 in the game, I just want it to remove one) :
` function checkspace() local g = game.Workspace:GetChildren() for i = 1,#g do local f = g[i]:FindFirstChild("FutureChair") f:remove()
end end
script.Parent.MouseButton1Down:connect(onButtonClicked)`
Model = game.Workspace["FutureChair"]; script.Parent.MouseButton1Click:connect(function(Clicked) Model:Destroy() end)
You showed a for loop, for loops will get all the children thats in the parent.
I may be misinterpreting your intention, but it seems like this is what you want:
function onButtonClicked() local g = game.Workspace:GetChildren() for i ,v in pairs(g) do local f = v:FindFirstChild("FutureChair") if f then f:Destroy() break end end end script.Parent.MouseButton1Down:connect(onButtonClicked)
model=[[MODELNAME]]; script.Parent.MouseButton1Down:connect(function() if Workspace:FindFirstChild(model) then Workspace[model]:Destroy(); end; end);