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: Door Script

Previous Thread :: Next Thread 
yellowcrash10 is not online. yellowcrash10
Joined: 20 Jul 2010
Total Posts: 152
21 Jul 2011 10:14 AM
Hello everyone! I am trying to work on a script so that when I (ONLY me) say "open" or "close," the door will open or close. I'm a little new to the scripting thing, but I think i'm getting the hang of it. Here is what my script looks like now:

door = script.Parent

game.Players.ChildAdded:connect(function(player)
if player.Name == "yellowcrash10" then
player.Chatted:connect(function(msg)

if (msg == "open") then
door.CanCollide = false
door.Transparency = 0.4

if (msg == "close") then
door.CanCollide = true
door.Transparency = 0
end
end
end
end)

I'm sure it's entirely messed up, but does anyone see any problems?
Report Abuse
Ozzypig is not online. Ozzypig
Joined: 27 Mar 2008
Total Posts: 4906
21 Jul 2011 10:17 AM
I wouldn't use an anonymous function right there, but oh well.

You should also being using if-elseif blocks.

example:

if msg == "open" then
--code
elseif msg == "close" then
--code
end

You'll only need one end statement.

~Ozzy
Report Abuse
yellowcrash10 is not online. yellowcrash10
Joined: 20 Jul 2010
Total Posts: 152
21 Jul 2011 10:30 AM
Thanks for the help! Would the anonymous work in the first place?
Report Abuse
Ozzypig is not online. Ozzypig
Joined: 27 Mar 2008
Total Posts: 4906
21 Jul 2011 10:30 AM
Yes, but in this kind of case you can use it.
Report Abuse
yellowcrash10 is not online. yellowcrash10
Joined: 20 Jul 2010
Total Posts: 152
21 Jul 2011 10:36 AM
OK. Thanks again! :)
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