Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

"Reference" the location of an object?

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

1 answer

✓ Accepted answer

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

3 comments

0

ObjectValue sounds perfect! Can't believe I didn't notice that... I'll try it out. Thanks!

0

It works!

0

Sweet(:

This discussion is preserved as it was. New answers, comments, and votes are closed.