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

Light Changer Script not working?

Asked by 6 years ago
Edited 6 years ago

Hey there, thank you for opening my question, I've asked this question a long time ago, but no one could answer it.

Question : Why is my Light Changer Script not working?

Here's the script!

local t = game.StarterGui.ChangeGUI.Text
local weather = game.ServerStorage.zomApocalypseWeather

if t.Text "example" then weather.Parent = game.Lightning
if t.Text "example2" then weather.Parent = game.ServerStorage

end

Any understandable help would mean so much to me. Thanks for reading this!

0
You need to put 2 ends ieatandisbaconhair 77 — 6y

2 answers

Log in to vote
0
Answered by 6 years ago

Hi BuzzKillGT! It looks like this script could use some improvements. This question is also lacking some information, but I will do the best I can to help you out. :)

I noticed at the beginning of the script, you seem to be attempting to change a non-existent property.

local t = game.StarterGui.ChangeGUI.Text

It seems you are attempting to change a "ScreenGui's" property, although.. ScreenGui's do not have a text property. (Woops!) However, we can add a text label to the ScreenGui.

You can add the object manually, or insert the object using one of ROBLOX's built in functions called "Instance.new()"

Here is an edited version of your script with that function implemented.

local ui = game.StarterGui:WaitForChild("ChangeGUI")
local t = Instance.new("TextLabel", ui)
local weather = game.ServerStorage.zomApocalypseWeather

if t.Text "example" then weather.Parent = game.Lightning
if t.Text "example2" then weather.Parent = game.ServerStorage

end

There! Now we have some text in our gui. Although, it looks like this script still needs some improvements.

Your script has two if statements, and only 1 end. Your if statements also are a bit broken, and to be honest. You only need 1 if statement for this script. :b

Lets out this to work, i'll do my best to explain along the way, but here is a link that may help you in the future!

https://www.robloxdev.com/articles/Conditional-Statements-in-Lua

This link contains a lot of useful information, so please consider taking the time to read through it.

Now lets fix up this script.

local ui = game.StarterGui:WaitForChild("ChangeGUI")
local t = Instance.new("TextLabel", ui)
local weather = game.ServerStorage.zomApocalypseWeather

if t.Text == "example" then 
    weather.Parent = game.Lightning --uh oh we had a typo here! I've replaced "Lightning" with "Lighting"..Lightning is not a child of game, and probably dosnt exist tbh.--
 --"==" means "is equal to" or "is exactly equal to" so if the arguments do not match, the commands after "then" wont run (until you close your if statement of course) --

elseif t.Text  == "example2" then 
    weather.Parent = game.ServerStorage
--elseif is a really useful statement that goes after an if in an if..elseif block of code. If the first argument does not match, the script will check if the second argument matches. If either match, the commands specified will run. Otherwise, the script will ignore this block of code until called to run it again.--

end
--we don't need 2 ends anymore now that we only have 1 if statement. I hope this helps! Btw in a Lua script, anything between double dashes (like this) will be completely ignore by the script. Hope I helped!--

This concludes my answer, I hope I helped! Let me know if you have anymore questions by commenting on this answer.

0
I've tried to put "elseif" in the script, however it got the red line below it for reasons. BuzzKillGT 33 — 6y
0
"Text" is actually the name of the text label, it isn't the property in a screen GUI. BuzzKillGT 33 — 6y
0
"Text" is actually a changing text, just to let you know. BuzzKillGT 33 — 6y
0
For anyone curious, we took this up in dm's. So if anyone is having the problem above, contact me for a full explanation. EtherealTrin 45 — 6y
0
Trin#4889 dont read this :3 BuzzKillGT 33 — 6y
Ad
Log in to vote
0
Answered by 6 years ago

You're missing an end

local t = game.StarterGui.ChangeGUI.Text

local weather = game.ServerStorage.zomApocalypseWeather

if t.Text "example" then 
    weather.Parent = game.Lightning
end
if t.Text "example2" then 
    weather.Parent = game.ServerStorage
end
0
You left out a lot of stuff ;b EtherealTrin 45 — 6y
0
cough i tried doing that but cough it has a red line BuzzKillGT 33 — 6y

Answer this question