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
We use cookies to offer you a better experience. By using Roblox.com, you are agreeing to our Privacy and Cookie Policy.
   
ROBLOX Forum » ROBLOX Fun » Look What I Made
Home Search
 

Re: OnTouch Function Question

Previous Thread :: Next Thread 
KoopaLab is not online. KoopaLab
Joined: 21 Mar 2007
Total Posts: 10
23 Mar 2007 11:36 AM
Hio, so here is my question. Can you set up a onTouch function so that instead of having a humanoid touching the brick to start the function could you make it so that it would need to be touched by a certian brick? Not just a brick and not humaniods, but only a specific brick. I have tried this and havent really gotten it to work... It might be a really easy answer.... lol

Koopa
Report Abuse
Telamon is not online. Telamon
Joined: 30 Jan 2007
Total Posts: 3614
23 Mar 2007 11:56 AM
Hello Koopa,

There is a clever way that you can do this. When you connect to the Touched event of a Part, onTouched will be called every time another Part hits it. The colliding part is passed into the onTouched handler as a parameter. In the example below, that parameter is the variable called "hit". If we want to make a special key that needs to touch the door before it can open, we can make another brick, name it "Key", and then do this:

print("Simple Secret Door Script Loaded")
Door = script.Parent
function onTouched(hit)
if (hit.Name == "Key") then
print("Door Unlocked")
end
end

connection = Door.Touched:connect(onTouched)

Neat, huh? You could also make a script that does something whenever a Red part touches it, or whenever a big part touches it, or whenever a ball touches it, ect ect.

On thing - BM says that if you are dragging a part over another part, no Touch events are fired until the part is dropped. Also no Touch events will be fired if the dragged brick snaps to the listening brick. So making a door like this may or may not be tricky.

-T
Report Abuse
KoopaLab is not online. KoopaLab
Joined: 21 Mar 2007
Total Posts: 10
23 Mar 2007 12:02 PM
Sweet! good, i have some great ideas for this. Thanks Telamon. I got to get this one stuck in my head so i remember it now.


Koopa
Report Abuse
koopa is not online. koopa
Joined: 07 Nov 2006
Total Posts: 1028
29 Mar 2007 02:00 PM
So, instead of starting a whole new thread, i am just reviving this old one since i have a question along with the same topic. I have tried this, which is exactly what was said above.


print("Simple Secret Door Script Loaded")
Door = script.Parent
function onTouched(hit)
if (hit.Name == "Key") then
print("Door Unlocked")
end
end

connection = Door.Touched:connect(onTouched)

Problem is, i never get the "Door Unlocked" in my output window. I have tried adding after the print Door.Transparency = 0.5 just so it would be more visible but nothing happens. I have also tried labeling what "Key" is, so i did something like this.

game.Workspace.Key = Key

Key = ("Key")

I did it like that and not like this because i kept getting a error message.

game.Workspace.Key = ("Key")

So, i am not sure how to actually get this to work now... lol Is there something i am not doing correctly? As always, and helpfull comments are greatly appreciated.

Koopa
Report Abuse
KoopaMapMaker is not online. KoopaMapMaker
Joined: 24 Mar 2007
Total Posts: 17
30 Mar 2007 01:40 PM
Sorry, but this needs a bump... So Bumpity bump.

Koopa
Report Abuse
stang90 is not online. stang90
Joined: 03 Sep 2006
Total Posts: 5633
30 Mar 2007 02:25 PM
so your sorta makein a door that opens whith a key?
Report Abuse
koopa is not online. koopa
Joined: 07 Nov 2006
Total Posts: 1028
30 Mar 2007 02:29 PM
Not quite... at least not yet lol, but yes thats the general idea.

Koopa
Report Abuse
miked is not online. miked
Joined: 15 Nov 2006
Total Posts: 430
30 Mar 2007 02:38 PM
Name an actual brick "Key" and make it touch it, if this is not what you are doing already. I dont see why it should not work.



The stuff after the actual script has errors:
1. game.Workspace.Key = Key
- You cant do this, did you mean to put:
Key = game.Workspace.Key

2. game.Workspace.Key = ("Key")
- game.Workspace.Key is a part, and you are telling the part to become a string, which you just cant do. If you are trying to name it you must do:
game.Workspace.Key.Name = "Key"





Report Abuse
koopa is not online. koopa
Joined: 07 Nov 2006
Total Posts: 1028
30 Mar 2007 02:44 PM
Ya, the first one is probably just a typo. I will try what you said for the second part. That couldave been my problem. Thanks for the suggestions! :)

Koopa
Report Abuse
koopa is not online. koopa
Joined: 07 Nov 2006
Total Posts: 1028
30 Mar 2007 02:49 PM
Yup, like you said Miked i just needed that one little part to be like this.

game.Workspace.Key.Name = "Key"

It works great now, thanks for the help! TY

Koopa
Report Abuse
jcs801 is not online. jcs801
Joined: 29 Mar 2012
Total Posts: 69675
14 Jun 2013 04:59 AM
bump lol umad



#9 top poster, #5 top active
Report Abuse
jcs802 is not online. jcs802
Joined: 22 Sep 2012
Total Posts: 100802
14 Jun 2013 05:01 AM
11 lol still a long time secret forum
JOIN MY PRIMARY PEOPLE NOWWWWWWWWWWWWW
Report Abuse
jcs802 is not online. jcs802
Joined: 22 Sep 2012
Total Posts: 100802
14 Jun 2013 05:01 AM
12 lol still a long time secret forum
JOIN MY PRIMARY PEOPLE NOWWWWWWWWWWWWW
Report Abuse
jcs802 is not online. jcs802
Joined: 22 Sep 2012
Total Posts: 100802
14 Jun 2013 05:02 AM
13 lol still a long time secret forum
JOIN MY PRIMARY PEOPLE NOWWWWWWWWWWWWW
Report Abuse
jcs802 is not online. jcs802
Joined: 22 Sep 2012
Total Posts: 100802
14 Jun 2013 05:03 AM
14 lol still a long time secret forum
JOIN MY PRIMARY PEOPLE NOWWWWWWWWWWWWW
Report Abuse
jcs802 is not online. jcs802
Joined: 22 Sep 2012
Total Posts: 100802
14 Jun 2013 05:03 AM
15 lol still a long time secret forum
JOIN MY PRIMARY PEOPLE NOWWWWWWWWWWWWW
Report Abuse
jcs802 is not online. jcs802
Joined: 22 Sep 2012
Total Posts: 100802
14 Jun 2013 05:04 AM
16 lol still a long time secret forum
JOIN MY PRIMARY PEOPLE NOWWWWWWWWWWWWW
Report Abuse
jcs802 is not online. jcs802
Joined: 22 Sep 2012
Total Posts: 100802
14 Jun 2013 05:04 AM
17 lol still a long time secret forum
JOIN MY PRIMARY PEOPLE NOWWWWWWWWWWWWW
Report Abuse
jcs802 is not online. jcs802
Joined: 22 Sep 2012
Total Posts: 100802
14 Jun 2013 05:05 AM
18 lol still a long time secret forum
JOIN MY PRIMARY PEOPLE NOWWWWWWWWWWWWW
Report Abuse
jcs802 is not online. jcs802
Joined: 22 Sep 2012
Total Posts: 100802
14 Jun 2013 05:06 AM
19 lol still a long time secret forum
JOIN MY PRIMARY PEOPLE NOWWWWWWWWWWWWW
Report Abuse
jcs802 is not online. jcs802
Joined: 22 Sep 2012
Total Posts: 100802
14 Jun 2013 05:06 AM
20 lol still a long time secret forum
JOIN MY PRIMARY PEOPLE NOWWWWWWWWWWWWW
Report Abuse
jcs802 is not online. jcs802
Joined: 22 Sep 2012
Total Posts: 100802
14 Jun 2013 05:07 AM
21 lol still a long time secret forum
JOIN MY PRIMARY PEOPLE NOWWWWWWWWWWWWW
Report Abuse
jcs802 is not online. jcs802
Joined: 22 Sep 2012
Total Posts: 100802
14 Jun 2013 05:07 AM
22 lol still a long time secret forum
JOIN MY PRIMARY PEOPLE NOWWWWWWWWWWWWW
Report Abuse
jcs802 is not online. jcs802
Joined: 22 Sep 2012
Total Posts: 100802
14 Jun 2013 05:08 AM
23 lol still a long time secret forum
JOIN MY PRIMARY PEOPLE NOWWWWWWWWWWWWW
Report Abuse
jcs802 is not online. jcs802
Joined: 22 Sep 2012
Total Posts: 100802
14 Jun 2013 05:08 AM
24 lol still a long time secret forum
JOIN MY PRIMARY PEOPLE NOWWWWWWWWWWWWW
Report Abuse
Previous Thread :: Next Thread 
Page 1 of 1
 
 
ROBLOX Forum » ROBLOX Fun » Look What I Made
   
 
   
  • 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