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: Problems with touch event- expect stupid mistakes

Previous Thread :: Next Thread 
pinballboy7 is not online. pinballboy7
Joined: 12 Mar 2009
Total Posts: 1485
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 is not online. ZQFMGB12
Joined: 07 Aug 2010
Total Posts: 208
21 Aug 2014 08:16 PM
connect should not be capitalized.
Report Abuse
pinballboy7 is not online. pinballboy7
Joined: 12 Mar 2009
Total Posts: 1485
21 Aug 2014 08:22 PM
It still doesn't work.
Report Abuse
ZQFMGB12 is not online. ZQFMGB12
Joined: 07 Aug 2010
Total Posts: 208
21 Aug 2014 08:23 PM
Any error messages?
Report Abuse
pinballboy7 is not online. pinballboy7
Joined: 12 Mar 2009
Total Posts: 1485
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 is not online. 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
pinballboy7 is not online. pinballboy7
Joined: 12 Mar 2009
Total Posts: 1485
21 Aug 2014 08:28 PM
Oh, okay. Thanks.
Report Abuse
pinballboy7 is not online. pinballboy7
Joined: 12 Mar 2009
Total Posts: 1485
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 is not online. 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 is not online. 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
pinballboy7 is not online. pinballboy7
Joined: 12 Mar 2009
Total Posts: 1485
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 is not online. 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
pinballboy7 is not online. pinballboy7
Joined: 12 Mar 2009
Total Posts: 1485
21 Aug 2014 09:02 PM
Still not working.
Report Abuse
JarodOfOrbiter is not online. JarodOfOrbiter
Joined: 17 Feb 2011
Total Posts: 20029
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 is not online. ZQFMGB12
Joined: 07 Aug 2010
Total Posts: 208
21 Aug 2014 09:02 PM
What's happening?
Report Abuse
islandmaker2012 is not online. islandmaker2012
Joined: 07 Nov 2012
Total Posts: 9327
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 is not online. 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 is not online. 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 is not online. ZQFMGB12
Joined: 07 Aug 2010
Total Posts: 208
21 Aug 2014 09:09 PM
I mean the script I helped edit...
Report Abuse
pinballboy7 is not online. pinballboy7
Joined: 12 Mar 2009
Total Posts: 1485
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 is not online. 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
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