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 » Scripters
Home Search
 

Re: Why doesn't this light script work? (I'm new - don't judge!)

Previous Thread :: Next Thread 
Castlemore is not online. Castlemore
Joined: 15 Sep 2013
Total Posts: 14737
11 May 2017 11:29 AM
lamp=script.Parent
white=lamp.PointLight
red=lamp.SpotLight

function SwitchToRed()
wait(.01)
white.Enabled=false
red.Enabled=true
lamp.BrickColor=BrickColor.new'Bright red'
end

function SwitchToWhite()
wait(.01)
white.Enabled=true
red.Enabled=false
lamp.BrickColor=BrickColor.new'White'
end

emergency=game.Lighting.Emergency

wait(.1)
emergency.Value.Changed:connect(function(newvalue)
if newvalue==true then
SwitchToRed()
elseif newvalue==false then
SwitchToWhite()
end


Report Abuse
Calviski is not online. Calviski
Joined: 03 Dec 2016
Total Posts: 209
11 May 2017 11:30 AM
lamp=script.Parent
white=lamp.PointLight
red=lamp.SpotLight

is meant to be

lamp = script.Parent
white = lamp.PointLight
red = lamp.SpotLight
Report Abuse
Castlemore is not online. Castlemore
Joined: 15 Sep 2013
Total Posts: 14737
11 May 2017 11:31 AM
Er.. spacing doesn't have anything to do with it. What's the actual problem?


Report Abuse
Intern33t is not online. Intern33t
Joined: 19 Nov 2010
Total Posts: 1530
11 May 2017 11:33 AM
"What's the actual problem?"

we could just ask you the same question
Report Abuse
InedibleGames is not online. InedibleGames
Joined: 27 Apr 2014
Total Posts: 1140
11 May 2017 11:36 AM
lamp.BrickColor=BrickColor.new'White'
You need brackets
lamp.BrickColor=BrickColor.new('White')
Report Abuse
Castlemore is not online. Castlemore
Joined: 15 Sep 2013
Total Posts: 14737
11 May 2017 11:36 AM
I don't know, Intern. I checked Output and all it gave was 'add an extra end' so here is the updated script (still not working for some reason). Is it a problem with the functions or the Changed?

lamp=script.Parent
white=lamp.PointLight
red=lamp.SpotLight

function SwitchToRed()
wait(.01)
white.Enabled=false
red.Enabled=true
lamp.BrickColor=BrickColor.new'Bright red'
end

function SwitchToWhite()
wait(.01)
white.Enabled=true
red.Enabled=false
lamp.BrickColor=BrickColor.new'White'
end

emergency=game.Lighting.Emergency

wait(.1)
emergency.Value.Changed:connect(function(newvalue)
if newvalue==true then
SwitchToRed()
elseif newvalue==false then
SwitchToWhite()
end


Report Abuse
Castlemore is not online. Castlemore
Joined: 15 Sep 2013
Total Posts: 14737
11 May 2017 11:38 AM
Brackets has nothing to do with it... and neither does spacing. Why do you guys keep suggesting things about formatting? There's clearly an issue with the actual script.

Forget it. I'll find out the problem myself. >.<


Report Abuse
Intern33t is not online. Intern33t
Joined: 19 Nov 2010
Total Posts: 1530
11 May 2017 11:38 AM
1st you dont need brackets, function"string argument" is fine

2nd,

emergency.Value.Changed:connect(function(newvalue)
...
end

dont you see anything?

:connect(function(newvalue)

you have an opening bracket

the last end should be

end)
Report Abuse
Castlemore is not online. Castlemore
Joined: 15 Sep 2013
Total Posts: 14737
11 May 2017 11:45 AM
Thanks Intern. Glad someone knows how to script around here... BUT...

{...}
wait(.1)
emergency.Value.Changed:connect(function(newvalue)
if newvalue==true then
SwitchToRed()
elseif newvalue==false then
SwitchToWhite()
end end)


Still doesn't work when I go in Play Solo and switch the Emergency value on and off.


Report Abuse
Intended_Pun is not online. Intended_Pun
Joined: 10 Aug 2016
Total Posts: 4384
11 May 2017 12:07 PM
View > Output

Look for errors.
Report Abuse
Castlemore is not online. Castlemore
Joined: 15 Sep 2013
Total Posts: 14737
11 May 2017 12:15 PM
Nope.. still can't find a problem and I've tried around three different scripts.


Report Abuse
devHoodie is online. devHoodie
Joined: 04 Nov 2008
Total Posts: 30332
11 May 2017 12:50 PM
emergency..Changed:connect(function(newvalue)
if newvalue==true then
SwitchToRed()
elseif newvalue==false then
SwitchToWhite()
end
end)
Report Abuse
devHoodie is online. devHoodie
Joined: 04 Nov 2008
Total Posts: 30332
11 May 2017 12:50 PM
Oops take out one of the dots after emergency
Report Abuse
devHoodie is online. devHoodie
Joined: 04 Nov 2008
Total Posts: 30332
11 May 2017 12:51 PM
or do this

emergency:GetPropertyChangedSignal("Value"):connect(function(newvalue)

if newvalue==true then
SwitchToRed()
elseif newvalue==false then
SwitchToWhite()
end

end)
Report Abuse
Castlemore is not online. Castlemore
Joined: 15 Sep 2013
Total Posts: 14737
11 May 2017 12:55 PM
@devHoodie:

Just tried that and it's still broken! D: Here is a gyo link to show you the issue:

bcd7eb52655e4eb52d084a15e012a598


Report Abuse
devHoodie is online. devHoodie
Joined: 04 Nov 2008
Total Posts: 30332
11 May 2017 12:56 PM
emergency:GetPropertyChangedSignal("Value"):connect(function()

if Emergency.Value == true then
SwitchToRed()
else
SwitchToWhite()
end

end)


i suggest you put emergency into ServerStorage
Report Abuse
Castlemore is not online. Castlemore
Joined: 15 Sep 2013
Total Posts: 14737
11 May 2017 01:04 PM
Nope. Still broken. Seriously, why is this so hard to script for god's sake? Not directed to you or anything but all this is is making the brick do something when a value is set to true or false. ><


Report Abuse
devHoodie is online. devHoodie
Joined: 04 Nov 2008
Total Posts: 30332
11 May 2017 01:05 PM
Are you getting any errors?
Report Abuse
InedibleGames is not online. InedibleGames
Joined: 27 Apr 2014
Total Posts: 1140
11 May 2017 01:54 PM
'Thanks Intern. Glad someone knows how to script around here'

If you're such a good scripter why don't you do it yourself?
Report Abuse
Castlemore is not online. Castlemore
Joined: 15 Sep 2013
Total Posts: 14737
11 May 2017 01:56 PM
I'm not a good scripter.. that's why I'm asking for help ><


Report Abuse
InedibleGames is not online. InedibleGames
Joined: 27 Apr 2014
Total Posts: 1140
11 May 2017 01:57 PM
So why are you assuming the people who tried to help can't script ^-^?
Report Abuse
InedibleGames is not online. InedibleGames
Joined: 27 Apr 2014
Total Posts: 1140
11 May 2017 01:59 PM
emergency=game.Lighting.Emergency

wait(.1)
emergency.Changed:connect(function()
print "Checking if changed"
if emergency.Value==true then
SwitchToRed()
elseifemergency.Value==false then
SwitchToWhite()
end
end)

Try it
Report Abuse
Castlemore is not online. Castlemore
Joined: 15 Sep 2013
Total Posts: 14737
11 May 2017 02:06 PM
@Inedible:

Thank you!

Sorry if it came out wrong too lol. I meant in reference to the people who were literally suggesting "change the brackets and speech marks". I get them every scripting help thread I post (which I rarely do post) >_<

Ty again ^_^


Report Abuse
InedibleGames is not online. InedibleGames
Joined: 27 Apr 2014
Total Posts: 1140
11 May 2017 02:26 PM
Welcomez sorry for coming off rude I thought you had to have the brackets lmao
Report Abuse
Previous Thread :: Next Thread 
Page 1 of 1
 
 
ROBLOX Forum » Game Creation and Development » Scripters
   
 
   
  • 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