generic image
Processing...
  • Games
  • Catalog
  • Develop
  • Robux
  • Search in Players
  • Search in Games
  • Search in Catalog
  • Search in Groups
  • Search in Library
  • Log In
  • Sign Up
  • Games
  • Catalog
  • Develop
  • Robux
   
ROBLOX Forum » Game Creation and Development » Scripting Helpers
Home Search
 

Re: Script Error on the Light Switch

Previous Thread :: Next Thread 
BenHall4433 is not online. BenHall4433
Joined: 10 Oct 2011
Total Posts: 842
30 Jul 2013 05:18 AM
function onClicked()
    script.Parent.Parent.Part1.SpotLight.Enabled = true
    script.Parent.Parent.Part2.SpotLight.Enabled = true
    script.Parent.Parent.Part3.SpotLight.Enabled = true
    script.Parent.Parent.Part4.SpotLight.Enabled = true
else
    script.Parent.Parent.Part1.SpotLight.Enabled = false
    script.Parent.Parent.Part2.SpotLight.Enabled = false
    script.Parent.Parent.Part3.SpotLight.Enabled = false
    script.Parent.Parent.Part4.SpotLight.Enabled = false
end
end

script.Parent.ClickDetector.MouseClick:connect(onClicked)

--The "else" was wriggled as red for an Error, but I don't know how to fix this error.
Report Abuse
Gogeta is not online. Gogeta
Joined: 25 Nov 2006
Total Posts: 583
30 Jul 2013 05:23 AM
Insert a String Value into the brick with the value labeled as Disabled.
function onClicked()
if script.Parent.StringValue.Value = "Disabled"
script.Parent.StringValue.Value = "Enabled"
script.Parent.Parent.Part1.SpotLight.Enabled = true
script.Parent.Parent.Part2.SpotLight.Enabled = true
script.Parent.Parent.Part3.SpotLight.Enabled = true
script.Parent.Parent.Part4.SpotLight.Enabled = true
else if script.Parent.StringValue.Value = "Enabled"
script.Parent.StringValue.Value = "Disabled"
script.Parent.Parent.Part1.SpotLight.Enabled = false
script.Parent.Parent.Part2.SpotLight.Enabled = false
script.Parent.Parent.Part3.SpotLight.Enabled = false
script.Parent.Parent.Part4.SpotLight.Enabled = false
end
end
end

script.Parent.ClickDetector.MouseClick:connect(onClicked)
Report Abuse
Gogeta is not online. Gogeta
Joined: 25 Nov 2006
Total Posts: 583
30 Jul 2013 05:24 AM
I'm sorry it's this.
function onClicked()
if script.Parent.StringValue.Value = "Disabled" then
script.Parent.StringValue.Value = "Enabled"
script.Parent.Parent.Part1.SpotLight.Enabled = true
script.Parent.Parent.Part2.SpotLight.Enabled = true
script.Parent.Parent.Part3.SpotLight.Enabled = true
script.Parent.Parent.Part4.SpotLight.Enabled = true
else if script.Parent.StringValue.Value = "Enabled" then
script.Parent.StringValue.Value = "Disabled"
script.Parent.Parent.Part1.SpotLight.Enabled = false
script.Parent.Parent.Part2.SpotLight.Enabled = false
script.Parent.Parent.Part3.SpotLight.Enabled = false
script.Parent.Parent.Part4.SpotLight.Enabled = false
end
end
end

script.Parent.ClickDetector.MouseClick:connect(onClicked)
Report Abuse
BenHall4433 is not online. BenHall4433
Joined: 10 Oct 2011
Total Posts: 842
30 Jul 2013 05:27 AM
Do I have to add the Value into a part?
Report Abuse
BenHall4433 is not online. BenHall4433
Joined: 10 Oct 2011
Total Posts: 842
30 Jul 2013 05:30 AM
It don't work.
Report Abuse
Gogeta is not online. Gogeta
Joined: 25 Nov 2006
Total Posts: 583
30 Jul 2013 05:31 AM
Yes.
Report Abuse
BenHall4433 is not online. BenHall4433
Joined: 10 Oct 2011
Total Posts: 842
30 Jul 2013 05:39 AM
ClassName = StringValue
Name = Value
Parent = Part1
Value = Disabled

Am I correct in this property?
Report Abuse
Gogeta is not online. Gogeta
Joined: 25 Nov 2006
Total Posts: 583
30 Jul 2013 05:42 AM
Name should just be StringValue the value is correct.
Report Abuse
Kondou is not online. Kondou
Joined: 05 Aug 2012
Total Posts: 1148
30 Jul 2013 06:05 AM
local spp = script.Parent.Parent
function onClicked()

if spp.Part1.SpotLight.Enabled == false then
spp.Part1.SpotLight.Enabled = true
spp.Part2.SpotLight.Enabled = true
spp.Part3.SpotLight.Enabled = true
spp.Part4.SpotLight.Enabled = true
else
spp.Part1.SpotLight.Enabled = false
spp.Part2.SpotLight.Enabled = false
spp.Part3.SpotLight.Enabled = false
spp.Part4.SpotLight.Enabled = false
end
end
script.Parent.ClickDetector.MouseClick:connect(onClicked)

[WIJ Corporal] Kondou
Report Abuse
Previous Thread :: Next Thread 
Page 1 of 1
 
 
ROBLOX Forum » Game Creation and Development » Scripting Helpers
   
 
   
  • About Us
  • Jobs
  • Blog
  • Parents
  • Help
  • Terms
  • Privacy

©2017 Roblox Corporation. Roblox, the Roblox logo, Robux, Bloxy, and Powering Imagination are among our registered and unregistered trademarks in the U.S. and other countries.



Progress
Starting Roblox...
Connecting to Players...
R R

Roblox is now loading. Get ready to play!

R R

You're moments away from getting into the game!

Click here for help

Check Remember my choice and click Launch Application in the dialog box above to join games faster in the future!

Gameplay sponsored by:
Loading 0% - Starting game...
Get more with Builders Club! Join Builders Club
Choose Your Avatar
I have an account
generic image