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: What is wrong with this script?

Previous Thread :: Next Thread 
robloxguyjoe is not online. robloxguyjoe
Joined: 27 Oct 2011
Total Posts: 60
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 is not online. 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
robloxguyjoe is not online. robloxguyjoe
Joined: 27 Oct 2011
Total Posts: 60
30 Sep 2013 12:17 PM
Thank you!
Report Abuse
sncplay42 is not online. 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
robloxguyjoe is not online. robloxguyjoe
Joined: 27 Oct 2011
Total Posts: 60
30 Sep 2013 12:23 PM
Yes greenon and redoff in workspace is all lowercase.
Report Abuse
robloxguyjoe is not online. robloxguyjoe
Joined: 27 Oct 2011
Total Posts: 60
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 is not online. 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
robloxguyjoe is not online. robloxguyjoe
Joined: 27 Oct 2011
Total Posts: 60
30 Sep 2013 12:36 PM
Not really :P ill go check out that link :3.
Report Abuse
robloxguyjoe is not online. robloxguyjoe
Joined: 27 Oct 2011
Total Posts: 60
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
robloxguyjoe is not online. robloxguyjoe
Joined: 27 Oct 2011
Total Posts: 60
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 is not online. 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
robloxguyjoe is not online. robloxguyjoe
Joined: 27 Oct 2011
Total Posts: 60
30 Sep 2013 03:20 PM
I meant the mouse click bit.
Report Abuse
sncplay42 is not online. 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
robloxguyjoe is not online. robloxguyjoe
Joined: 27 Oct 2011
Total Posts: 60
01 Oct 2013 09:59 AM
Im pretty sure iv done that. theres click detectors in greenon and redoff
Report Abuse
robloxguyjoe is not online. robloxguyjoe
Joined: 27 Oct 2011
Total Posts: 60
03 Oct 2013 10:33 AM
Whoo i did it.
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