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: Making a button-toggleable light?

Previous Thread :: Next Thread 
Cravitus is not online. Cravitus
Joined: 03 Aug 2012
Total Posts: 139
15 Jul 2013 02:06 PM
Trying to attach a script for a toggleable light to a gun I'm making.

That said, right now I just want to get the light's brick to change from black to shiny white.

What I have is not working.

function Flashlight()
if key == "F" then
wait(0.4)
Light = {tool.Light}
if Light.Brickcolor "Really black"
then
Light.Brickcolor = BrickColor.new("Institutional white")
Light.Reflectance = 0.5
else
Light.Brickcolor = BrickColor.new ("Really Black")
Light.Reflectance = 0
end
end
end


What am I doing wrong?
Report Abuse
blocco is not online. blocco
Joined: 14 Aug 2008
Total Posts: 29474
15 Jul 2013 02:07 PM
No object in Roblox has a property named "Brickcolor". I suspect that you meant "BrickColor".
Report Abuse
Cravitus is not online. Cravitus
Joined: 03 Aug 2012
Total Posts: 139
15 Jul 2013 02:08 PM
Ah, that may be the problem. First time scripter.
Report Abuse
blocco is not online. blocco
Joined: 14 Aug 2008
Total Posts: 29474
15 Jul 2013 02:09 PM
Also, `Light` is probably not meant to be a table. I suggest removing those curly brackets around "tool.Light", as you mean to use it as an Instance.
Report Abuse
Cravitus is not online. Cravitus
Joined: 03 Aug 2012
Total Posts: 139
15 Jul 2013 02:29 PM
Bump.

function Flashlight()
wait(0.4)
if Tool.light.BrickColor "Really black"
then
Tool.light.BrickColor = BrickColor.new("Light blue")
Tool.light.Reflectance = 0.5
else
Tool.light.BrickColor = BrickColor.new ("Really Black")
Tool.light.Reflectance = 0
end
end

Still not working, but I think it has something to do with the keypress.

function KeyDownFunctions(key)
if key == "r" then
Reload()
end
if key == "F" then
Flashlight()
end
end
Report Abuse
Notunknown99 is not online. Notunknown99
Joined: 05 Sep 2008
Total Posts: 25360
15 Jul 2013 02:39 PM
Tool.light.BrickColor "Really black"

Tool.light.BrickColor == BrickColor.new("Really black")
Report Abuse
Notunknown99 is not online. Notunknown99
Joined: 05 Sep 2008
Total Posts: 25360
15 Jul 2013 02:40 PM
In your if statement.
Report Abuse
Cravitus is not online. Cravitus
Joined: 03 Aug 2012
Total Posts: 139
15 Jul 2013 02:48 PM
Doesn't seem to work, though the gun's been working the way it should the entire time. 'Cept for the flashlight of course.
Report Abuse
Notunknown99 is not online. Notunknown99
Joined: 05 Sep 2008
Total Posts: 25360
15 Jul 2013 02:57 PM
Oh, and your 'F' needs to be 'f'.
Report Abuse
Cravitus is not online. Cravitus
Joined: 03 Aug 2012
Total Posts: 139
15 Jul 2013 03:01 PM
Thanks, now it works!
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