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

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

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?

2 comments

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.

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.

1 answer

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.

1 comment

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.

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