I'm making a game where you can place buildings. When you click on the building, it copies its GUI into PlayerGui and opens up a window with buttons. One of these buttons should be able to delete the building... however, I don't know how to "reference" back to the building!
If I do script.Parent it'll just spit out "PlayerGui". So... is there any way to store the location of the building model when the GUI is created, then use it to delete the model at a later time?
P.S. I know this is a bit... well, a lot... confusing. Let me know in the comments if there's something you guys don't understand
Thanks, Nikola7007
A good way to do this is to 'tag' the building using an ObjectValue.
For example, when you're cloning the gui into the player's playergui then put an objectvalue in the gui with a value of the building..
local gui = game.ServerStorage:FindFirstChild('HypotheticalGui') if gui then local newGui = gui:Clone() newGui.Parent = Player.PlayerGui --Tag it-- local obj = Instance.new('ObjectValue',newGui) obj.Name = 'HouseReference' obj.Value = House ---------- end