|
| 30 Sep 2013 12:07 PM |
So im trying to make a light with a switch. the off button iv named redoff, the on button called greenon and the block with the point light in is called block. I am hopeless at scriping, so could you give me a heads up how to fix this. This is the script:
print 'Hello world!' local light = workspace.block.light local redoff = workspace.redoff local greenon = workspace.greenon
function onclicked (greenon) light.enabled = false wait (1) light.enabled = true end
greenon.clicked.light: enabled (onclick)
function onclicked (redoff) light = enabled wait (1) light = disabled end
redoff.clicked.light: disabled (onclick)
extra info: the on and off buttons have click detector. the script is just in workspace. to start i set the light to disabled, because the idea is when u click green button it comes on, and when you click red it goes off. this script is probable totaly wrong. if i think of anything else, ill comment. if you need any more detailed info, just ask.
Please help! |
|
|
| Report Abuse |
|
|
chaokid9
|
  |
| Joined: 29 Aug 2008 |
| Total Posts: 6187 |
|
|
| 30 Sep 2013 12:15 PM |
Quite a few problems, I put notes next to them
print ('Hello world!') --You forgot the parentheses, this is needed in any function. local light = Workspace.block.light local redoff = Workspace.redoff local greenon = Workspace.greenon -- All of these 'workspace' need to be capitalized
function onclickedGreen (clicker) -- The thing in parentheses is the name of who clicked it, not the brick print(clicker) -- see how it prints your name when you click it? The line above dfines "Clicker" light.Enabled = false wait (1) light.Enabled = true -- Both Enableds need to be capitalized. end
greenon.MouseClick:connect(onclickedGreen) -- this line was very messed up, just look what I changed it to.
function onclickedRed (clicker) -- Changed name so it wouldn't be the same as the first function. light.Enabled = true wait (1) light.Enabled = false end
redoff.ClickDetector.MouseClick:connect(onclickedRed) -- changed again |
|
|
| Report Abuse |
|
|
| |
|
sncplay42
|
  |
| Joined: 27 Nov 2008 |
| Total Posts: 11891 |
|
|
| 30 Sep 2013 12:18 PM |
> -- All of these 'workspace' need to be capitalized
Just FYI I believe both "workspace" and "Workspace" are defined and work.
Also it's worth asking if the names of light, redoff and greenon in the workspace are actually lowercase. |
|
|
| Report Abuse |
|
|
|
| 30 Sep 2013 12:23 PM |
| Yes greenon and redoff in workspace is all lowercase. |
|
|
| Report Abuse |
|
|
|
| 30 Sep 2013 12:33 PM |
@choakid9 I copy and pasted your script lines into a script in workspace, but it didnt seem to work, the place im testing is is one of my active places script testing. |
|
|
| Report Abuse |
|
|
sncplay42
|
  |
| Joined: 27 Nov 2008 |
| Total Posts: 11891 |
|
|
| 30 Sep 2013 12:33 PM |
Do you know about the output window?
http://wiki.roblox.com/index.php/Output |
|
|
| Report Abuse |
|
|
|
| 30 Sep 2013 12:36 PM |
| Not really :P ill go check out that link :3. |
|
|
| Report Abuse |
|
|
|
| 30 Sep 2013 12:39 PM |
Oh in workspace block was Block. heres what output said: Hello world! 18:38:09.663 - block is not a valid member of Workspace 18:38:09.669 - Script 'Workspace.Script', Line 2 18:38:09.670 - stack end
Ill change it to block, I need to remember this case sensitivity :P |
|
|
| Report Abuse |
|
|
|
| 30 Sep 2013 12:40 PM |
Right fixed that but now: Hello world! 18:39:48.060 - "Part.light" should be "Light" in Workspace.Script 18:39:48.062 - MouseClick is not a valid member of Part 18:39:48.063 - Script 'Workspace.Script', Line 13 18:39:48.065 - stack end
Do you know how i can fix it? |
|
|
| Report Abuse |
|
|
sncplay42
|
  |
| Joined: 27 Nov 2008 |
| Total Posts: 11891 |
|
|
| 30 Sep 2013 01:04 PM |
"Part.light" should be "Light"
Sounds pretty simple to follow to me. |
|
|
| Report Abuse |
|
|
|
| 30 Sep 2013 03:20 PM |
| I meant the mouse click bit. |
|
|
| Report Abuse |
|
|
sncplay42
|
  |
| Joined: 27 Nov 2008 |
| Total Posts: 11891 |
|
|
| 30 Sep 2013 05:12 PM |
You have to add a ClickDetector; parts themselves can't detect mouse clicks.
http://wiki.roblox.com/index.php/ClickDetector |
|
|
| Report Abuse |
|
|
|
| 01 Oct 2013 09:59 AM |
| Im pretty sure iv done that. theres click detectors in greenon and redoff |
|
|
| Report Abuse |
|
|
| |
|