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

How do I get this Light script to work? (UNSOLVED)

Asked by 10 years ago

Today I have have tried making a script for the Light which I am currently working on. Now I am hiving minor problems to this script on a Surface Gui.

So here is the script.

01script.Parent.MouseButton1Down:connect(function()
02script.Parent.Parent.Parent.Parent.DynamicLight1.PointLight.Enabled = true
03script.Parent.Parent.Parent.Parent.DynamicLight2.PointLight.Enabled = true
04script.Parent.Parent.Parent.Parent.DynamicLight3.PointLight.Enabled = true
05script.Parent.Parent.Parent.Parent.DynamicLight4.PointLight.Enabled = true
06script.Parent.Parent.Parent.Parent.DynamicLight5.PointLight.Enabled = true
07script.Parent.Parent.Parent.Parent.DynamicLight6.PointLight.Enabled = true
08script.Parent.Parent.Parent.Parent.DynamicLight7.PointLight.Enabled = true
09script.Parent.Parent.Parent.Parent.DynamicLight8.PointLight.Enabled = true
10script.Parent.Parent.Parent.Parent.DynamicLight9.PointLight.Enabled = true
11script.Parent.Parent.Parent.Parent.DynamicLight10.PointLight.Enabled = true
12script.Parent.Parent.Parent.Parent.DynamicLight11.PointLight.Enabled = true
13script.Parent.Text = "Turn Off" -- I can't get this to work!
14script.Parent.BackgroundColor3 = {170,0,0} -- And also, this!
15wait(5) -- I want this to be changed to an function where you can turn it off instead of doing it on a timing.
View all 31 lines...
0
I'd be glad to help but I have no clue what the parent of your script is. It might be good idea to define this to use or we can't really help Bman8765 270 — 10y
0
You also might want to consider adding your values to a table... Tortelloni 315 — 10y

3 answers

Log in to vote
0
Answered by 10 years ago

Line 14 is incorrect. Explained in comments:

1script.Parent.BackgroundColor3 = Color3.new(170,0,0) --You didn't define the value, it is a Color3 value.

Other than that, I can't really help with the changing of the Text, but I would assume it is a Hierarchy error. Make sure your Hierarchy is correct.

If you want a function to change it, rather than a loop, you can use the MouseButton1Click event on a TextButton.

01local on = false
02 
03function onClicked()
04    if on == false then
05        on = true
06        --add the turning on code
07    elseif on == true then
08        on = false
09        -add the turning off code
10    end
11end
12 
13script.Parent.MouseButton1Click:connect(onClicked) --This line is assuming the TextButton is the script's parent.
Ad
Log in to vote
0
Answered by 10 years ago

Thanks for the script, but however the switching on works - but when you press the button again, it don't seem to be doing anything. Is there a glitch in the script or is it something to do with my model?

Log in to vote
0
Answered by 10 years ago
1function onClicked()
2 
3 
4[Your Script Here]
5 
6script.Parent.MouseButton1Click:connect(onClicked)

Try replacing the function/event with this, if that doesn't work, I have no clue.

(Unless you already did this step). Also, if you want to turn it off again than do another light switch I guess like: you can do visible = false after the script was executed and visible the light off switch gui.

Answer this question