I need to destroy a billboard gui with a script so basically i put a billboard gui, a click detector, and a local script in an object and i want to destroy the billboard gui when i click the object ( heres my failed code )
function onClicked () script.Parent.BillboardGui:Destroy() end script.Parent.ClickDetector.MouseClick:connect(onClicked) onClicked()
alright so for my click giver script , i put the code in the same script as the one for the destroy gui script above. it goes somewhere along the lines of this ( it doesnt work, what did i do wrong )
local debounce = false function onClick() if debounce = false then Lighting.Tool:clone().Parent = player.Backpack end end onClick()
my tool is in lighting . sorry if this is suppose to be super easy but i just started scripting and gotten a small hang of it some of the code is copied from some free models and yeah. thanks for reading
Unless you have a variable for it, the issue would seem to be that you're accessing Lighting
as if it's a global variable. You might need to use game.Lighting
instead.
Another thing to note is that clone
is deprecated. You should be using Clone
instead. (notice the case difference)
Here's a revised version of the line where you clone said tool.
game.Lighting.Tool:Clone().Parent = player.Backpack
Lastly, I'd suggest that rather than storing assets in Lighting
, you store them in ReplicatedStorage
instead. There's no real difference, but ReplicatedStorage
is the most widely-used for this sort of occasion. Lighting
was never meant for storing assets.