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

How to make a working textButton inside a billboard gui to delete an object?

Asked by 6 years ago

For a sandbox/tycoon game im making, im trying to make a BillboardGUI with a TextButton that when you click it, it should delete a placed object. Here's the script:

function onClick()
    script.Parent.Parent.Parent.Parent = nil
end

script.Parent.MouseButton1Click:connect(onClick)

When i click on the TextButton, it does nothing. How do i fix this?

0
Do not set the parent to nil it will not safely delete the part use Destroy(). GUIs should be local only. User remote events / functions to make changes server side. User#5423 17 — 6y
0
i replaced script.Parent.Parent.Parent.Parent = nil with print("success") and it still did absolutely nothing, with not even a single error message. VeryWowMuchDoge 47 — 6y

1 answer

Log in to vote
0
Answered by 6 years ago
function onClick()
    script.Parent.Parent.Parent.Parent:Destroy()
end

script.Parent.MouseButton1Click:connect(onClick)

nil is a value

use :Destroy() if you want to delete a part.

0
i replaced script.Parent.Parent.Parent.Parent = nil with print("success") and it still did absolutely nothing, with not even a single error message. VeryWowMuchDoge 47 — 6y
Ad

Answer this question