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: Clicking Dynamic Lighting

Previous Thread :: Next Thread 
kingbowler1040 is not online. kingbowler1040
Joined: 03 Oct 2011
Total Posts: 1202
27 Nov 2013 05:59 PM
I am making a game, I made a switch when players touch it, a light flashes on and plays a clicking noise.
Not exactly sure how to do it.

function onTouched()

Light = script.Parent
NewLight = Instance.new("PointLight",Light)
game.Workspace.Sound:play()
end

Light.Touched:connect(onTouched)


How do you do this?! It is supposed to Play a clicking sound and turn on a light when Touched, also, when you touch it again, it turns off. I am stumped. Normally, when I type this much I get no replies ):
Report Abuse
BruceAB12 is not online. BruceAB12
Joined: 19 Jan 2012
Total Posts: 3238
27 Nov 2013 06:02 PM
Use a debounce, then just set the pointlight to enabled or disabled according to the debounce's value

E.G:

debounce = false

if debounce then
NewLight.Enabled = true
elseif not debounce then
NewLight.Enabled = false
end


Report Abuse
kingbowler1040 is not online. kingbowler1040
Joined: 03 Oct 2011
Total Posts: 1202
27 Nov 2013 06:05 PM
Hope it goes at the top of the script.
Report Abuse
kingbowler1040 is not online. kingbowler1040
Joined: 03 Oct 2011
Total Posts: 1202
27 Nov 2013 06:09 PM
Doesn't work. I wanted this function for a more realistic game feature.
Output: Global "NewLight" a nil value

Should I try the bottom of the script?
Report Abuse
BruceAB12 is not online. BruceAB12
Joined: 19 Jan 2012
Total Posts: 3238
27 Nov 2013 06:10 PM
....
Of course it isn't going to work that was just an example.
Report Abuse
kingbowler1040 is not online. kingbowler1040
Joined: 03 Oct 2011
Total Posts: 1202
27 Nov 2013 06:13 PM
-_-
Report Abuse
BruceAB12 is not online. BruceAB12
Joined: 19 Jan 2012
Total Posts: 3238
27 Nov 2013 06:17 PM
Light = script.Parent
debounce = false
NewLight = Instance.new("PointLight",Light)
NewLight.Enabled = false

Light.Touched:connect(function()
Game.Workspace.Sound:Play()
if debounce then
debounce = false
NewLight.Enabled = false
elseif not debounce then
debounce = true
NewLight.Enabled = true
end
end)

That should work.
Report Abuse
Azarth is not online. Azarth
Joined: 17 Aug 2012
Total Posts: 2760
27 Nov 2013 06:18 PM
http://www.roblox.com/light-item?id=136790746
Report Abuse
kingbowler1040 is not online. kingbowler1040
Joined: 03 Oct 2011
Total Posts: 1202
27 Nov 2013 06:47 PM
Thx you.
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