What do I need to type to make a TextLabel show different text? This is my script:
script.Parent.MouseButton1Click:connect(function() game.StarterGui.ScreenGui.OrderCurrent.Text = "Milkshake" print ("itworks") end)
"itworks" gets printed in chat, however, the TextLabel called "OrderCurrent" does not say Milkshake. I am aware I will have to use RemoteEvents, but I want to get this sorted first.
Additionally, I want clicking the TextButton to display the change to the whole server. I am making this for a cafe game and want to make a system where a cashier presses a button (which has an item of food written on it) and the chefs see the order on a TextLabel at the top of their screen. This can be made in a different way, such as a system message in chat, but this method is fine.
Any gui in StarterGui gets cloned into PlayerGui when the game starts, meaning that you need to look for the gui in PlayerGui. Try this:
local playerGui = game.Players.LocalPlayer:WaitForChild("PlayerGui") script.Parent.MouseButton1Click:connect(function() playerGui.ScreenGui.OrderCurrent.Text = "Milkshake" print("itworks") end)
PlayerGuis are 100% ClientSide so you don't need to worry about passing it through RemoteEvents. So switch your script to a LocalScript and use this-
player = game.Players.LocalPlayer script.Parent.MouseButton1Click:connect(function() player.PlayerGui.ScreenGui.OrderCurrent.Text = "Milkshake" end)
PlayerGui's will act the same with StarterGui. They are connected. Try:
script.Parent.MouseButton1Click:Connect(function() --Change if it's in a different script game.StarterGui.ScreenGui.OrderCurrent.Text = "Milkshake" end)