I will make a GUI. For a Cafe, when click menu, there should be drinks. When you click one of the drinks, the order appears on the orders board. So I need the script for that.
1 Like
The easy way to do this is with 2 scripts.
One localscript and one server script that communicates with a remote event to say what drink was clicked, and by what player.
What should I write in scripts?
Scripting support is not a place where you go to request an entire script, you must attempt the problem and we will help you with the errors if any.
ServerScript
local remote = game:GetService("ReplicatedStorage"):FindFirstChild("RemoteEvent");
remote.OnServerEvent:Connect(function(player, drinkName)
local template = script:FindFirstChild("Template"):Clone(); --I would use a TextLabel that's already sized properly
template.Text = string.format("%s ordered a %s", player.Name, drinkName); --"MrLonely1221 ordered a Caramel Mocha"
template.Parent = workspace:FindFirstChild("Signs"):FindFirstChild("Holder"); --Move it to the billboard that's there so everyone can see it.
end);
LocalScript
local remote = game:GetService("ReplicatedStorage"):FindFirstChild("RemoteEvent");
--Loop through buttons to connect to them.
for index, buttonObj in ipairs(script.Parent:GetChildren()) do --Put this script in a frame that has all the buttons
if buttonObj:IsA("TextButton") or buttonObj:IsA("ImageButton") then
buttonObj.Activated:Connect(function()
remote:FireServer(buttonObj.Name); --Make sure the buttons are named after the drink, or make a way to handle the drink name on the server.
end);
end;
end;
3 Likes