|
| 21 Aug 2014 08:15 PM |
I have past experience with Lua, but I decided to do the Roblox wiki's scripting tutorials...and I've managed to get stuck on the "absolute beginner's guide", where I'm trying to script a brick to react to being touched by another object. I messed around, to no avail. I attempted to follow several tutorials on youtube. Here's what I ended up trying to make work:
function onTouch() block.Transparency = 1 wait(1) block.Transparency = 0 end
block = game.Workspace.Blocky block.Touched:Connect(onTouch)
I put the script in workspace, but it's not working. I'm very inexperienced, so I assume I did something really obvious and stupid. Could someone help? |
|
|
| Report Abuse |
|
|
ZQFMGB12
|
  |
| Joined: 07 Aug 2010 |
| Total Posts: 208 |
|
|
| 21 Aug 2014 08:16 PM |
| connect should not be capitalized. |
|
|
| Report Abuse |
|
|
| |
|
ZQFMGB12
|
  |
| Joined: 07 Aug 2010 |
| Total Posts: 208 |
|
| |
|
|
| 21 Aug 2014 08:25 PM |
| No...but it suddenly works now...several minutes after doing anything to the script. I think Roblox may just hate me. Thanks anyways. |
|
|
| Report Abuse |
|
|
ZQFMGB12
|
  |
| Joined: 07 Aug 2010 |
| Total Posts: 208 |
|
|
| 21 Aug 2014 08:26 PM |
| If you're on build mode (developing with your player present), you have to disable then enable the script to reset it. |
|
|
| Report Abuse |
|
|
| |
|
|
| 21 Aug 2014 08:30 PM |
| Wait...it only works if I run it from the command line. Any idea why that would happen? |
|
|
| Report Abuse |
|
|
ZQFMGB12
|
  |
| Joined: 07 Aug 2010 |
| Total Posts: 208 |
|
|
| 21 Aug 2014 08:32 PM |
| Just put the code in a script. I tested it out (changing your error) and it works. |
|
|
| Report Abuse |
|
|
iiLezso
|
  |
| Joined: 23 Mar 2010 |
| Total Posts: 255 |
|
|
| 21 Aug 2014 08:37 PM |
So lets make things a bit easier ok?
Add a script into the Block
do
script.Parent.Touched:connect(function(onTouch) script.Parent.Transparency = 1 wait(1) script.Parent.Transparency = 0 end)
Hope it helps!
Ubuntu is cool! |
|
|
| Report Abuse |
|
|
|
| 21 Aug 2014 08:50 PM |
| Neither of those work. Maybe I just have a really terrible superpower- making scripts fail for no reason. :( |
|
|
| Report Abuse |
|
|
ZQFMGB12
|
  |
| Joined: 07 Aug 2010 |
| Total Posts: 208 |
|
|
| 21 Aug 2014 08:52 PM |
Go on edit mode, then play solo. There are no problems with the scripts.
|
|
|
| Report Abuse |
|
|
| |
|
|
| 21 Aug 2014 09:02 PM |
| Make sure the script is enabled. Check the output, and also make sure the game is running. Click the green arrow to run the game. |
|
|
| Report Abuse |
|
|
ZQFMGB12
|
  |
| Joined: 07 Aug 2010 |
| Total Posts: 208 |
|
| |
|
|
| 21 Aug 2014 09:04 PM |
deb = false function Touch(Block,Block2) if not deb then deb = true Block.Transparency = 1 wait(1) Block.Transparency = 0 end end
block = Workspace.Blocky block.Touched:connect(function(hit) Touch(block,hit) end)
--normal script in workspace, in EDIT mode |
|
|
| Report Abuse |
|
|
ZQFMGB12
|
  |
| Joined: 07 Aug 2010 |
| Total Posts: 208 |
|
|
| 21 Aug 2014 09:08 PM |
You don't need block.Touched:connect(function(hit) Touch(block,hit) end) block.Touched:connect(functionName) is good enough. |
|
|
| Report Abuse |
|
|
ZQFMGB12
|
  |
| Joined: 07 Aug 2010 |
| Total Posts: 208 |
|
|
| 21 Aug 2014 09:08 PM |
| The script I gave above already works (I tested it). |
|
|
| Report Abuse |
|
|
ZQFMGB12
|
  |
| Joined: 07 Aug 2010 |
| Total Posts: 208 |
|
|
| 21 Aug 2014 09:09 PM |
| I mean the script I helped edit... |
|
|
| Report Abuse |
|
|
|
| 21 Aug 2014 09:13 PM |
| Okay...it seems to have suddenly decided to work, despite me not changing anything. Thanks for the help, though. I'll remember to script in edit mode and test in solo mode. |
|
|
| Report Abuse |
|
|
ZQFMGB12
|
  |
| Joined: 07 Aug 2010 |
| Total Posts: 208 |
|
|
| 21 Aug 2014 09:15 PM |
You should do everything in edit mode and test in solo mode. If you made a stupid building mistake (such as a model unexpectedly falling apart), you can always undo it. On build mode, you have to build it all over again. |
|
|
| Report Abuse |
|
|