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 where if you hit the submit button it well add the order frame to the chef ui -
What is the issue? Include screenshots / videos if possible!
I’m trying to make an ordering system in on the submit button part of when you hit the ordersubmit button it is supposed to add the order frame to the chef ui but it’s not doing that Here, my client 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 orderSubmitButton = gui.OrderFrame.ImageLabel:WaitForChild("submit") -- Add the submit button here
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
createFoodLabel(baseClicked, "chocolate chip")
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, "red velvet")
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)
orderSubmitButton.MouseButton1Click:Connect(function()
-- Send the order to the server
OrderBoardEvent:FireServer(order)
print("Order submitted: " .. table.concat(order, ", "))
end)
VerifyUsernameEvent.OnClientEvent:Connect(function(success)
if success then
gui.NameFrame.Visible = false
nextFrame.Visible = true
else
warn("Username not found on the server.")
end
end)
OrderBoardEvent.OnClientEvent:Connect(function(order)
-- Add the order to the ChefFrame for all players
local playerGui = LocalPlayer:WaitForChild("PlayerGui")
local orderFrame = playerGui:WaitForChild("ChefFrame")
local chefFrame = orderFrame.ImageLabel.ScrollingFrame:WaitForChild("template")
local frame = Instance.new("Frame")
frame.Position = UDim2.new(0.007, 0, 0, 0) -- Position at the top initially
frame.Size = UDim2.new(0, 518, 0, 115) -- Adjusted to be full width and height of the template
frame.Parent = chefFrame
local textButton = Instance.new("TextButton")
textButton.Text = "claim"
textButton.TextScaled = true
textButton.BackgroundColor3 = Color3.new(170/255, 255/255, 0) -- Ensure color range is correct
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)
and hers my server script
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local OrderSubmitted = ReplicatedStorage:WaitForChild("OrderSubmitted")
local VerifyUsernameEvent = ReplicatedStorage:WaitForChild("VerifyUsername")
local OrderBoardEvent = ReplicatedStorage:WaitForChild("OrderBoardEvent")
local Players = game:GetService("Players")
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 BroadcastOrder(order)
OrderBoardEvent:FireAllClients(order)
end
OrderBoardEvent.OnServerEvent:Connect(function(player, order)
BroadcastOrder(order)
end)
OrderSubmitted.OnServerEvent:Connect(function(player, order)
-- Add the order to the ChefFrame for all players
for _, p in Players:GetPlayers() do
local playerGui = p:FindFirstChild("PlayerGui")
if playerGui then
local orderFrame = playerGui:FindFirstChild("ChefFrame")
if orderFrame then
local chefFrame = orderFrame.ImageLabel.ScrollingFrame:FindFirstChild("template")
if chefFrame then
local frame = Instance.new("Frame")
frame.Position = UDim2.new(0.007, 0, 0, 0) -- Position at the top initially
frame.Size = UDim2.new(0, 518, 0, 115) -- Adjusted to be full width and height of the template
frame.Parent = chefFrame
local textButton = Instance.new("TextButton")
textButton.Text = "claim"
textButton.TextScaled = true
textButton.BackgroundColor3 = Color3.new(170/255, 255/255, 0) -- Ensure color range is correct
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
end
end
end
end)