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:
