Hey, I really need your help, I can't seem to make the script to work.
~~~~~~~~~~~~~~~~~
local speedRunWeather = game.ServerStorage.speedRunWeather local t = game.StarterGui.changeGUI.Text if t.Text "Hey, this is a text." then speedRunWeather.Parent = game.Lightning
I would really appreciate if you guys could help me, thank you!
(filtering enabled, i put the script in serverscriptserver)
an if statement should be formatted like this
if foo == bar then print('Hello World!') end
EDIT:
so your code should be like this.
local speedRunWeather = game.ServerStorage.speedRunWeather local t = game.StarterGui.changeGUI if t.Text == "Hey, this is a text." then speedRunWeather.Parent = game.Lightning end
It also should be noted that when changing text on a gui, don't save the text as a variable,
Variables in RLua have many types (ex. Bool, String, Instance, etc.)
When you save a variable like you did before
Reference:
local t = game.StarterGui.changeGUI.Text
It saves the Text property of the Instance as a String variable. This means that when you change it later in your code, it isn't changing the text that is on the TextLabel, it is changing the Text variable.
Example:
local textLabel = Instance.new('TextLabel') textLabel.Text = 'foo' local Text = textLabel.Text -- The variable "Text" now equals 'foo' print(Text) -- Prints 'foo' textLabel.Text = 'bar' -- We set the TextLabel's text to 'bar' print(Text) -- Still prints 'foo'
The way to do it correctly is to save the Text variable as the TextLabel's Instance. (Or just reference the TextLabel directly every time)
Example:
local textLabel = Gui.Notification textLabel.Text = 'foo' -- or just do Gui.Notification.Text = 'foo'
Doing this allows you to change the instance's Text property directly, instead of what you did before (saving the text property as a variable).
BuzzKillGT for line 4 you did:
if t.Text "Hey, this is a text."
you forgot to add a equal sign, so it didnt work -
if t.Text == ("Hey, this is a text.") then
and dont use use variables to store text, because if u change the text it doesnt update it, so use it directly(idk how to say it lol).