Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

How do I make a TextLabel change Text?

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.

1 comment

0

is it a localscript or a script? and where is it located?

3 answers

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)

1 comment

0

It's seems not working for me.. But also upvoted.

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)

1 comment

0

Really? Someone replied to my previous post saying I'd need to use RemoteEvents.

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)

This discussion is preserved as it was. New answers, comments, and votes are closed.