|
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! |
|
|
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 |
|
|
sncplay42Join Date: 2008-11-27 Post Count: 11891 |
> -- 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. |
|
|
Yes greenon and redoff in workspace is all lowercase. |
|
|
@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. |
|
sncplay42Join Date: 2008-11-27 Post Count: 11891 |
|
|
|
Not really :P ill go check out that link :3. |
|
|
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 |
|
|
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? |
|
sncplay42Join Date: 2008-11-27 Post Count: 11891 |
"Part.light" should be "Light"
Sounds pretty simple to follow to me. |
|
|
I meant the mouse click bit. |
|
sncplay42Join Date: 2008-11-27 Post Count: 11891 |
You have to add a ClickDetector; parts themselves can't detect mouse clicks.
http://wiki.roblox.com/index.php/ClickDetector |
|
|
Im pretty sure iv done that. theres click detectors in greenon and redoff |
|
|