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

Previous Thread :: Next Thread 
pokesal is not online. pokesal
Joined: 29 Oct 2010
Total Posts: 10751
08 Jul 2011 03:41 AM
I am new to scripting. I made this script:

local brick = Instance.new ("Part")
function onTouched(Hit)
brick.Transparency = 1
wait(2)
brick.Transparency = 0
end
end

game.Workspace.Part: connect onTouched(Hit)

Whenever I hit the brick, it doesn't perform the function. Can someone help me and show me the corrected script? Thank you.
Report Abuse
OBFAlt is not online. OBFAlt
Joined: 06 Jul 2011
Total Posts: 35
08 Jul 2011 03:46 AM
local brick = Instance.new("Brick")
brick.Parent = Workspace
function touch(hit)
brick.Transparency = 1
wait(2)
brick.Transparency = 0
end
brick.Touched:connect(touch)

That will make a new brick in the Workspace, and make in invisible then visible again when you touch it.
Report Abuse
pokesal is not online. pokesal
Joined: 29 Oct 2010
Total Posts: 10751
08 Jul 2011 03:50 AM
Where do I put the script? Because putting it in the brick doesn't work.
Report Abuse
OBFAlt is not online. OBFAlt
Joined: 06 Jul 2011
Total Posts: 35
08 Jul 2011 03:52 AM
You already have the brick?

script.Parent.Touched:connect(function()
script.Parent.Transparency = 1
wait(2)
script.Parent.Transparency = 0
end)
Report Abuse
pokesal is not online. pokesal
Joined: 29 Oct 2010
Total Posts: 10751
08 Jul 2011 03:53 AM
Yes. I already have the brick.
Report Abuse
OBFAlt is not online. OBFAlt
Joined: 06 Jul 2011
Total Posts: 35
08 Jul 2011 03:55 AM
Then put my second one in the brick.
Report Abuse
pokesal is not online. pokesal
Joined: 29 Oct 2010
Total Posts: 10751
08 Jul 2011 03:58 AM
Thanks. It works. Can you explain the first line of the script?
Report Abuse
bikerking200 is not online. bikerking200
Joined: 11 Mar 2010
Total Posts: 5047
08 Jul 2011 03:59 AM
The first line is a Connection line, Connection lines are the ones that make the script complete if you have a function
Report Abuse
pokesal is not online. pokesal
Joined: 29 Oct 2010
Total Posts: 10751
08 Jul 2011 04:01 AM
Okay. But doesn't the connection line usually go at the end of the script?
Report Abuse
pokesal is not online. pokesal
Joined: 29 Oct 2010
Total Posts: 10751
08 Jul 2011 04:03 AM
Also, I made this script to change its reflectance:

script.Parent.Touched:connect(function()
script.Parent.Reflectance = 1
wait(2)
script.Parent.Reflectance = 0
end)

Just change "Transparency" to "Reflectance" and it works.
Report Abuse
OBFAlt is not online. OBFAlt
Joined: 06 Jul 2011
Total Posts: 35
08 Jul 2011 04:13 AM
Oh, sorry. It's an anonymous function. It's the connection line and the function all mixed into one. :)
Report Abuse
pokesal is not online. pokesal
Joined: 29 Oct 2010
Total Posts: 10751
08 Jul 2011 04:17 AM
Can you still write it like this:

function onTouched(hit)
script.Parent.Transparency = 1
wait(2)
script.Parent.Transparency = 0
end
script.Parent.Touched:connect onTouched
Report Abuse
bikerking200 is not online. bikerking200
Joined: 11 Mar 2010
Total Posts: 5047
08 Jul 2011 05:09 AM
Ya.
Report Abuse
MassaIII is not online. MassaIII
Joined: 16 Mar 2008
Total Posts: 72
08 Jul 2011 05:25 AM
function onTouched(hit)
script.Parent.Transparency = 1
wait(2)
script.Parent.Transparency = 0
end
script.Parent.Touched:connect(onTouched) --You forgot the brackets here.
Report Abuse
pokesal is not online. pokesal
Joined: 29 Oct 2010
Total Posts: 10751
08 Jul 2011 06:47 AM
Yeah. I know. Also, is there a such thing as onClick?
Report Abuse
bikerking200 is not online. bikerking200
Joined: 11 Mar 2010
Total Posts: 5047
08 Jul 2011 06:49 AM
Yeah.


script.Parent.ClickDetector.MouseClick:connect(function()
script.Parent.Reflectance = 1
wait(2)
script.Parent.Reflectance = 0
end)
Report Abuse
zeke505 is not online. zeke505
Joined: 26 May 2008
Total Posts: 15765
08 Jul 2011 06:49 AM
Yes, for click detectors. But it does not return the player who clicked it.
Report Abuse
pokesal is not online. pokesal
Joined: 29 Oct 2010
Total Posts: 10751
08 Jul 2011 06:50 AM
So how would I make the brick change it's Transparency by clicking it?
Report Abuse
pokesal is not online. pokesal
Joined: 29 Oct 2010
Total Posts: 10751
08 Jul 2011 06:51 AM
Never mind.
Report Abuse
myrco919 is not online. myrco919
Joined: 12 Jun 2009
Total Posts: 13241
08 Jul 2011 06:52 AM
[ Content Deleted ]
Report Abuse
zeke505 is not online. zeke505
Joined: 26 May 2008
Total Posts: 15765
08 Jul 2011 06:52 AM
The same way you did using the touched function, just don't have an argument.
Report Abuse
pokesal is not online. pokesal
Joined: 29 Oct 2010
Total Posts: 10751
08 Jul 2011 06:55 AM
Okay. I got it. I thank everyone for their help.
Report Abuse
myrco919 is not online. myrco919
Joined: 12 Jun 2009
Total Posts: 13241
08 Jul 2011 06:57 AM
[ Content Deleted ]
Report Abuse
myrco919 is not online. myrco919
Joined: 12 Jun 2009
Total Posts: 13241
08 Jul 2011 06:57 AM
[ Content Deleted ]
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