Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

How do I make a TextLabel change Text?

Asked by 4 years ago
Edited 4 years ago

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.

0
is it a localscript or a script? and where is it located? bluzorro 417 — 4y

3 answers

Log in to vote
1
Answered by 4 years ago
Edited 4 years ago

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)
0
It's seems not working for me.. But also upvoted. Xapelize 2658 — 4y
Ad
Log in to vote
0
Answered by
Ruves 21
4 years ago
Edited 4 years ago

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)
0
Really? Someone replied to my previous post saying I'd need to use RemoteEvents. MinecraftButterfly87 10 — 4y
Log in to vote
0
Answered by 4 years ago

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)

Answer this question