Script not detecting if a text button is pressed

For context I’m attempting to create a Work at a Pizza Place style cashier system. I’ve created a script that works perfectly, until it comes to the part where it checks if a text button has been pressed. Any help and/or insight on what is going wrong would be deeply appreciated.

Script:

local chatService = game:GetService("Chat")

local customer = script.Parent.Customer
local tablet = script.Parent.Tablet
local guiFrame = tablet.SurfaceGui.Main
local orderValue = tablet.orderValue

local orderChoice

while task.wait(5) do
	orderChoice = math.random(1, 4)
	local function numberToString()
		if orderChoice == 1 then
			orderChoice = "Drink"
		elseif orderChoice == 2 then
			orderChoice = "Burger"
		elseif orderChoice == 3 then
			orderChoice = "Chips"
		elseif orderChoice == 4 then
			orderChoice = "Pizza"
		end
		orderValue.Value = orderChoice
	end
	numberToString()
	chatService:Chat(customer.Head, orderChoice)
end

function clicked(whichButton)
	print("RECIEVED!!!")
	if whichButton.Name == orderValue.Value then
		print("CORRECT!!!")
	else
		print("INCORRECT!!!")
	end
end

while true do 
	for _, button in ipairs({guiFrame.Drink, guiFrame.Burger, guiFrame.Chips, guiFrame.Pizza}) do
		button.MouseButton1Click:Connect(function()
			clicked(button)
		end)
	end
end

Hierarchy:
Screenshot 2024-03-12 200144

For surfaceGUIs to be interactive they must be parented to playerGUI (StarterGUI) with their ‘Adornee’ property set to the part you want it to be on.

2 Likes

I swapped it and nothing seemed to come of it, still nothing being printed in output. Thanks for trying to help though.

Thank you soo much! Should have been the first thing I checked. Been a while since I’ve used SurfaceGui’s and I evidently completely forgot how to properly use them.

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.