How to make button delete surface GUI?

Hi, i currently have a script that clones my receipts onto a menu board but whilst doing so it makes a button that says “DONE” visible. Im trying to work out how i can make the DONE button delete the surface GUI from the screen. It keeps giving me errors since the text button isnt a member of the OrderScreen Surface GUI, instead it just gets cloned into it when the receipt does.

Events.Checkout.OnServerEvent:Connect(function (Player, Order)


	CustomerScreen.Order.Visible = false
	CustomerScreen.Checkout.Visible = true
	local Receipt = game.ServerStorage.Receipt.Receipt.Receipt:Clone()	


	local BindableEvent = game.Workspace.Tech.Events.BindableEvent
	
	



	Receipt.Order.Text = Order

	Receipt.Parent = game.Workspace.OrderScreenGui
	
	Receipt.TextButton.Visible = true


end)

Heres my code that clones the receipt onto the screen as well as making the done button visible.

This Order board is located in workspace?(How does it work, Is that intentional) I was going to tell you that you shouldn’t be changing clientside UI via Serverside remotes. but I’m not entirely sure what’s going on with your system.

1 Like

I have the orderscreen in my workspace then the surface gui on it so then players can see the order on a large screen

Okay so I see, The workspace Screen is like the main, and the clients will just read and adjust to it.

Have you seen what line gives you the error

Is it this line?

Receipt.TextButton.Visible = true
1 Like

Currently when i play the game i dont get any errors. When i create an order on my cash register, the player is given a receipt as a tool in their backpack and the receipt also appears on the order screen with a “Done” button. But im looking to know how id make the DONE button remove the order from the main screen and whenever i try to code something to do so, it causes errors.

Was the text button the ‘Done’ Button

Give me a moment compiling a possible solution

1 Like

yes the textbutton is the done button

So I figured just add the done button onto this already existing function instead of making more clutter n scripts

This is what you have right now…

Receipt.TextButton.Visible = true

This is what I suggest doing

Receipt.TextButton.Visible = true

local DoneFunction
DoneFunction = Receipt.TextButton.MouseButton1Click:Connect(function() --// Might need different event idk
-- I might add something here idk (._.
DoneFunction:Disconnect()
 --//Discard Reciept Receipt:Destroy() or game.Debris:AddItem(Receipt,.1)
end)
1 Like

it brings up this error Workspace.Tech.CashRegisterScript:87: attempt to call a RBXScriptSignal value

I forgot :Connect(function() end)

:person_facepalming:

fixed :pensive: mybad

1 Like

That works now thankyou! My codes get soo confusing and im new to this so thankyou for your help!!

1 Like

No problemo :face_with_monocle: So happy to be of help

1 Like