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

Destroy gui via script help? and, click giver help?

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

1 comment

0

If you find an answer correct, you should flag it appropriately to be "correct"

1 answer

✓ Accepted answer

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.

4 comments

0

alright thanks!

0

Well, the 'ReplicatedStorage' service only replicates to a client; it will turn up as a 'nil' (void) service if a Server-Sided script attempts to call it/ get the service (through the 'GetService'/'FindService' methods). :)

0

@TheAlphaStigma Not sure what you're talking about; that's completely false.

0

I input the code with the tool in replicated storage and stuff, still doesnt work ( tried on lighting, doesnt work either )

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