|
| 18 May 2013 03:21 PM |
I need help fixing this, for some reason it won't work.
function onClicked() print("Hello World!")
if script.Parent.IsOff == true then script.Parent.IsOn.Value = true script.Parent.IsOff.Value = false
if script.Parent.IsOff == false then script.Parent.IsOn.Value = false script.Parent.IsOff.Value = true
if script.Parent.IsOn.Value == true then
script.Parent.Parent.CealingLight1.Light1.SpotLight.Enabled = true wait(0.1) script.Parent.Parent.CealingLight1.Light2.SpotLight.Enabled = true wait(1) script.Parent.Parent.CealingLight1.Light2.SpotLight.Enabled = false
while true do wait(0.1) script.Parent.Parent.CealingLight1.Light2.Sparkles.Enabled = false wait(0.1) script.Parent.Parent.CealingLight1.Light2.Sparkles.Enabled = true wait(0.1) script.Parent.Parent.CealingLight1.Light2.Sparkles.Enabled = false
if script.Parent.IsOn == true then script.Parent.Parent.CealingLight1.Light1.SpotLight.Enabled = false script.Parent.Parent.CealingLight1.Light2.SpotLight.Enabled = false script.Parent.Parent.CealingLight1.Light2.Sparkles.Enable = false
script.Parent.ClickDetector.MouseClick:connect(onClicked)
end end end end end end
|
|
|
| Report Abuse |
|
|
|
| 18 May 2013 03:33 PM |
function onClicked() print("Hello World!")
if script.Parent.IsOff == true then
script.Parent.IsOn.Value = true script.Parent.IsOff.Value = false
if script.Parent.IsOff == false then
script.Parent.IsOn.Value = false -------Isn't this turning it 'off'? script.Parent.IsOff.Value = true
if script.Parent.IsOn.Value == true -------It turned it off above...^ then
script.Parent.Parent.CealingLight1.Light1.SpotLight.Enabled = true wait(0.1) script.Parent.Parent.CealingLight1.Light2.SpotLight.Enabled = true wait(1) script.Parent.Parent.CealingLight1.Light2.SpotLight.Enabled = false
while true do wait(0.1) script.Parent.Parent.CealingLight1.Light2.Sparkles.Enabled = false wait(0.1) script.Parent.Parent.CealingLight1.Light2.Sparkles.Enabled = true wait(0.1) script.Parent.Parent.CealingLight1.Light2.Sparkles.Enabled = false
if script.Parent.IsOn == true then script.Parent.Parent.CealingLight1.Light1.SpotLight.Enabled = false script.Parent.Parent.CealingLight1.Light2.SpotLight.Enabled = false script.Parent.Parent.CealingLight1.Light2.Sparkles.Enable = false
script.Parent.ClickDetector.MouseClick:connect(onClicked)
end end end end end end
|
|
|
| Report Abuse |
|
|
L2000
|
  |
| Joined: 03 Apr 2008 |
| Total Posts: 77448 |
|
|
| 18 May 2013 03:35 PM |
Without looking through it fully, here's one big problem: It won't connect, because the connection line is inside the function.
function onClicked() print("Hello World!")
if script.Parent.IsOff == true then
script.Parent.IsOn.Value = true script.Parent.IsOff.Value = false
if script.Parent.IsOff == false then
script.Parent.IsOn.Value = false script.Parent.IsOff.Value = true
if script.Parent.IsOn.Value == true then
script.Parent.Parent.CealingLight1.Light1.SpotLight.Enabled = true wait(0.1) script.Parent.Parent.CealingLight1.Light2.SpotLight.Enabled = true wait(1) script.Parent.Parent.CealingLight1.Light2.SpotLight.Enabled = false
while true do wait(0.1) script.Parent.Parent.CealingLight1.Light2.Sparkles.Enabled = false wait(0.1) script.Parent.Parent.CealingLight1.Light2.Sparkles.Enabled = true wait(0.1) script.Parent.Parent.CealingLight1.Light2.Sparkles.Enabled = false
if script.Parent.IsOn == true then script.Parent.Parent.CealingLight1.Light1.SpotLight.Enabled = false script.Parent.Parent.CealingLight1.Light2.SpotLight.Enabled = false script.Parent.Parent.CealingLight1.Light2.Sparkles.Enable = false
end end end end end end
script.Parent.ClickDetector.MouseClick:connect(onClicked)
Might have a problem somewhere else, though. Didn't look through it.
-JB |
|
|
| Report Abuse |
|
|
| |
|
|
| 18 May 2013 03:37 PM |
| Thank L2000, I will see if that works. |
|
|
| Report Abuse |
|
|
|
| 18 May 2013 03:43 PM |
| @zackeryjerrypowers, No what it was supposed to do is if you click it while it's on then it turns it off, if you click it while it's off then it turns it on. |
|
|
| Report Abuse |
|
|
|
| 18 May 2013 03:44 PM |
Alrighty. :|
∂◊и'₮ サ∆₮∑ ◊и ₮サ∑ ㄅⅰббㄚ |
|
|
| Report Abuse |
|
|
|
| 18 May 2013 03:44 PM |
This is what I have now:
function onClicked() print("Hello World!")
if script.Parent.IsOff == true then
script.Parent.IsOn.Value = true script.Parent.IsOff.Value = false
if script.Parent.IsOff == false then
script.Parent.IsOn.Value = false script.Parent.IsOff.Value = true
if script.Parent.IsOn.Value == true then
script.Parent.Parent.CealingLight1.Light1.SpotLight.Enabled = true wait(0.1) script.Parent.Parent.CealingLight1.Light2.SpotLight.Enabled = true wait(1) script.Parent.Parent.CealingLight1.Light2.SpotLight.Enabled = false
while true do wait(0.1) script.Parent.Parent.CealingLight1.Light2.Sparkles.Enabled = false wait(0.1) script.Parent.Parent.CealingLight1.Light2.Sparkles.Enabled = true wait(0.1) script.Parent.Parent.CealingLight1.Light2.Sparkles.Enabled = false
if script.Parent.IsOn == true then script.Parent.Parent.CealingLight1.Light1.SpotLight.Enabled = false script.Parent.Parent.CealingLight1.Light2.SpotLight.Enabled = false script.Parent.Parent.CealingLight1.Light2.Sparkles.Enable = false
end end end end end end
script.Parent.ClickDetector.MouseClick:connect(onClicked)
|
|
|
| Report Abuse |
|
|
| |
|
| |
|
shooter06
|
  |
| Joined: 13 Jan 2011 |
| Total Posts: 7443 |
|
| |
|
Dr01d3k4
|
  |
| Joined: 11 Oct 2007 |
| Total Posts: 17916 |
|
|
| 18 May 2013 04:14 PM |
1) Spell "ceiling" correctly. 2) You don't need an "IsOn" and "IsOff" variable, just one will do. 3) Your ends are in the wrong place |
|
|
| Report Abuse |
|
|
|
| 18 May 2013 04:22 PM |
| @shooter, Output won't tell me the error. |
|
|
| Report Abuse |
|
|
|
| 18 May 2013 04:27 PM |
I got this now, same problem. Output just says "Hello World!" every time I click switch.
function onClicked() print("Hello World!")
if script.Parent.IsOff == true then
script.Parent.IsOff.Value = false
if script.Parent.IsOff == false then
script.Parent.IsOff.Value = true
end
if script.Parent.IsOff.Value == false then
script.Parent.Parent.CeilingLight1.Light1.SpotLight.Enabled = true wait(0.1) script.Parent.Parent.CeilingLight1.Light2.SpotLight.Enabled = true wait(1) script.Parent.Parent.CeilingLight1.Light2.SpotLight.Enabled = false
while true do wait(0.1) script.Parent.Parent.CeilingLight1.Light2.Sparkles.Enabled = false wait(0.1) script.Parent.Parent.CeilingLight1.Light2.Sparkles.Enabled = true wait(0.1) script.Parent.Parent.CeilingLight1.Light2.Sparkles.Enabled = false
if script.Parent.IsOff == true then script.Parent.Parent.CeilingLight1.Light1.SpotLight.Enabled = false script.Parent.Parent.CeilingLight1.Light2.SpotLight.Enabled = false script.Parent.Parent.CeilingLight1.Light2.Sparkles.Enable = false
end end end end end
script.Parent.ClickDetector.MouseClick:connect(onClicked)
|
|
|
| Report Abuse |
|
|
| |
|
|
| 18 May 2013 04:39 PM |
@Zeke, I get this:
16:38:59.597 - attempt to call a nil value 16:38:59.609 - Disconnected event because of exception |
|
|
| Report Abuse |
|
|
Dr01d3k4
|
  |
| Joined: 11 Oct 2007 |
| Total Posts: 17916 |
|
|
| 18 May 2013 04:40 PM |
@Zeke: That'd make it error.
local on = false; local lights = script.Parent.Parent.CeilingLight1;
local function setLight(n, o) lights["Light"..n].SpotLight.Enabled = o; end
local function setSparkes(n, o) lights["Light"..n].Sparkles.Enabled = o;
script.Parent.ClickDetector.MouseClick:connect(function () on = not on; if (on) then setLight(1, true); wait(0.1); setLight(2, true); wait(1); setLight(2, false); repeat wait(0.1); setSparkles(2, false); wait(0.1); setSparkles(2, true); wait(0.1); setSparkles(2, false); until (not on); setLight(1, false); setLight(2, false); setSparkles(2, false); end end); |
|
|
| Report Abuse |
|
|
|
| 18 May 2013 04:45 PM |
@Dr01d3k4 Didn't do anything. |
|
|
| Report Abuse |
|
|
dekkonot
|
  |
| Joined: 22 Dec 2010 |
| Total Posts: 6685 |
|
|
| 18 May 2013 04:59 PM |
local on = false function onClicked() -- Three lights on = not on
if on then script.Parent.Parent.CeilingLight1.Light1.SpotLight.Enabled = true wait(0.1) script.Parent.Parent.CeilingLight1.Light2.SpotLight.Enabled = true wait(1) script.Parent.Parent.CeilingLight1.Light2.SpotLight.Enabled = false end
while on and wait() do script.Parent.Parent.CeilingLight1.Light2.Sparkles.Enabled = false wait(0.1) script.Parent.Parent.CeilingLight1.Light2.Sparkles.Enabled = true wait(0.1) script.Parent.Parent.CeilingLight1.Light2.Sparkles.Enabled = false end
while not on and wait() do script.Parent.Parent.CeilingLight1.Light1.SpotLight.Enabled = false script.Parent.Parent.CeilingLight1.Light2.SpotLight.Enabled = false script.Parent.Parent.CeilingLight1.Light2.Sparkles.Enable = false end
end
script.Parent.ClickDetector.MouseClick:connect(onClicked)
~ Linguam latinam est optimum ~ |
|
|
| Report Abuse |
|
|
|
| 18 May 2013 05:02 PM |
| @dekkonot, Thanks it worked. |
|
|
| Report Abuse |
|
|
dekkonot
|
  |
| Joined: 22 Dec 2010 |
| Total Posts: 6685 |
|
|
| 18 May 2013 05:02 PM |
You are welcome.
~ Linguam latinam est optimum ~ |
|
|
| Report Abuse |
|
|