You can write your topic however you want, but you need to answer these questions:
-
What do you want to achieve? Keep it simple and clear!
I want it to add the order to the chef ui -
What is the issue? Include screenshots / videos if possible!
I’m trying to make an ordering system but when I try to make it where it will add the order to the chef ui it will break my username GUI that you enter the player username that’s on the server in I’m using the instant.new method to add the order to the chef ui Here is my client’s script
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local VerifyUsernameEvent = ReplicatedStorage:WaitForChild("VerifyUsername")
local OrderBoardEvent = ReplicatedStorage:WaitForChild("OrderBoardEvent")
local Players = game:GetService("Players")
local LocalPlayer = Players.LocalPlayer
local gui = script.Parent
local usernameInput = gui.NameFrame.ImageLable:WaitForChild("playername")
local submitButton = gui.NameFrame.ImageLable:WaitForChild("enter")
local nextFrame = gui:WaitForChild("OrderFrame")
local cookieButton = gui.OrderFrame.ImageLabel:WaitForChild("cookiebutton")
local donutButton = gui.OrderFrame.ImageLabel:WaitForChild("donutbutton")
local chocolatechipcookie = gui.OrderFrame.ImageLabel.cookies:WaitForChild("chocolatechipcookie")
local redvelvet = gui.OrderFrame.ImageLabel.cookies:WaitForChild("redvelvetcookie")
local vanilla = gui.OrderFrame.ImageLabel.cookies:WaitForChild("vanillacookie")
local labelCount = 0 -- Keep track of the number of labels added
local baseClicked = nil -- Track which base button (cookie or donut) was clicked
local order = {} -- Store the order details
submitButton.MouseButton1Click:Connect(function()
local username = usernameInput.Text
VerifyUsernameEvent:FireServer(username)
end)
local function createFoodLabel(baseName, specificName)
if labelCount >= 3 then
print("Maximum number of labels reached!")
return
end
local textlabel = Instance.new("TextLabel")
if specificName then
textlabel.Text = baseName .. " " .. specificName -- Combine the base name with the specific name
else
textlabel.Text = baseName -- Use the base name
end
textlabel.BackgroundTransparency = 1
textlabel.Size = UDim2.new(0, 147, 0, 34) -- Adjust size as needed
textlabel.Parent = gui.OrderFrame
-- Define specific positions for each slot
local positions = {
UDim2.new(6.12, 0, 1.33, 0), -- Slot 1
UDim2.new(7.69, 0, 1.34, 0), -- Slot 2
UDim2.new(9.233, 0, 1.34, 0) -- Slot 3
}
-- Assign the position based on the current labelCount
textlabel.Position = positions[labelCount + 1]
labelCount = labelCount + 1
-- Add the item to the order
table.insert(order, textlabel.Text)
end
cookieButton.MouseButton1Click:Connect(function()
baseClicked = "cookie"
if labelCount < 3 then
else
print("You can only add up to 3 items.")
end
end)
donutButton.MouseButton1Click:Connect(function()
baseClicked = "donut"
if labelCount < 3 then
else
print("You can only add up to 3 items.")
end
end)
chocolatechipcookie.MouseButton1Click:Connect(function()
if not baseClicked then
print("Please click the cookie or donut button first.")
return
end
if labelCount < 3 then
else
print("You can only add up to 3 items.")
end
end)
redvelvet.MouseButton1Click:Connect(function()
if not baseClicked then
print("Please click the cookie or donut button first.")
return
end
if labelCount < 3 then
createFoodLabel(baseClicked, "redvelvet")
else
print("You can only add up to 3 items.")
end
end)
vanilla.MouseButton1Click:Connect(function()
if not baseClicked then
print("Please click the cookie or donut button first.")
return
end
if labelCount < 3 then
createFoodLabel(baseClicked, "vanilla")
else
print("You can only add up to 3 items.")
end
end)
VerifyUsernameEvent.OnClientEvent:Connect(function(success)
if success then
gui.NameFrame.Visible = false
nextFrame.Visible = true
-- Send the order to the server
OrderBoardEvent:FireServer(order)
else
warn("Username not found on the server.")
end
end)
and here’s my server script
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local VerifyUsernameEvent = ReplicatedStorage:WaitForChild("VerifyUsername")
local OrderBoardEvent = ReplicatedStorage:WaitForChild("OrderBoardEvent")
local Players = game:GetService("Players")
local playergui = Players:WaitForChild("PlayerGui")
local orderframe = playergui:WaitForChild("ChefFrame")
local ChefFrame = orderframe.ImageLabel.ScrollingFrame:WaitForChild("template")
VerifyUsernameEvent.OnServerEvent:Connect(function(player, username)
for _, p in Players:GetPlayers() do
if p.Name == username then
VerifyUsernameEvent:FireClient(player, true)
return
end
end
VerifyUsernameEvent:FireClient(player, false)
end)
local function AddOrder(order)
local frame = Instance.new("Frame")
frame.Position = UDim2.new(0.007, 0, 1.207, 0)
frame.Size = UDim2.new(0.007, 0, 1.207, 0)
frame.Parent = ChefFrame
local Textbutton = Instance.new("TextButton")
Textbutton.Text = "claim"
Textbutton.TextScaled = true
Textbutton.BackgroundColor3 = Color3.new(170, 255, 0)
Textbutton.Size = UDim2.new(0, 142, 0, 115)
Textbutton.Position = UDim2.new(0, 0, 0, 0)
Textbutton.Parent = frame
local textlabel = Instance.new("TextLabel")
textlabel.Position = UDim2.new(0.351, 0, 0.277, 0)
textlabel.Size = UDim2.new(0, 199, 0, 54)
textlabel.Text = "Order: " .. table.concat(order, ", ")
textlabel.TextScaled = true
textlabel.Parent = frame
end
OrderBoardEvent.OnServerEvent:Connect(function(player, order)
AddOrder(order)
end)
`