Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

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

Asked by 9 years ago

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

0
If you find an answer correct, you should flag it appropriately to be "correct" Programmix 285 — 9y

1 answer

Log in to vote
0
Answered by 9 years ago

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.

0
alright thanks! OfficialAndreJosh 10 — 9y
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). :) TheeDeathCaster 2368 — 9y
0
@TheAlphaStigma Not sure what you're talking about; that's completely false. Programmix 285 — 9y
0
I input the code with the tool in replicated storage and stuff, still doesnt work ( tried on lighting, doesnt work either ) OfficialAndreJosh 10 — 9y
Ad

Answer this question