KoopaLabJoin Date: 2007-03-21 Post Count: 10 |
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 |
|
TelamonJoin Date: 2007-01-30 Post Count: 3614 |
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 |
|
KoopaLabJoin Date: 2007-03-21 Post Count: 10 |
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 |
|
koopaJoin Date: 2006-11-07 Post Count: 1028 |
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
|
|
|
Sorry, but this needs a bump... So Bumpity bump.
Koopa |
|
stang90Join Date: 2006-09-03 Post Count: 5633 |
so your sorta makein a door that opens whith a key? |
|
koopaJoin Date: 2006-11-07 Post Count: 1028 |
Not quite... at least not yet lol, but yes thats the general idea.
Koopa |
|
mikedJoin Date: 2006-11-15 Post Count: 430 |
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"
|
|
koopaJoin Date: 2006-11-07 Post Count: 1028 |
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 |
|
koopaJoin Date: 2006-11-07 Post Count: 1028 |
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 |
|
|
bump lol umad
#9 top poster, #5 top active |
|
jcs802Join Date: 2012-09-22 Post Count: 100802 |
11 lol still a long time secret forum
JOIN MY PRIMARY PEOPLE NOWWWWWWWWWWWWW |
|
jcs802Join Date: 2012-09-22 Post Count: 100802 |
12 lol still a long time secret forum
JOIN MY PRIMARY PEOPLE NOWWWWWWWWWWWWW |
|
jcs802Join Date: 2012-09-22 Post Count: 100802 |
13 lol still a long time secret forum
JOIN MY PRIMARY PEOPLE NOWWWWWWWWWWWWW |
|
jcs802Join Date: 2012-09-22 Post Count: 100802 |
14 lol still a long time secret forum
JOIN MY PRIMARY PEOPLE NOWWWWWWWWWWWWW |
|
jcs802Join Date: 2012-09-22 Post Count: 100802 |
15 lol still a long time secret forum
JOIN MY PRIMARY PEOPLE NOWWWWWWWWWWWWW |
|
jcs802Join Date: 2012-09-22 Post Count: 100802 |
16 lol still a long time secret forum
JOIN MY PRIMARY PEOPLE NOWWWWWWWWWWWWW |
|
jcs802Join Date: 2012-09-22 Post Count: 100802 |
17 lol still a long time secret forum
JOIN MY PRIMARY PEOPLE NOWWWWWWWWWWWWW |
|
jcs802Join Date: 2012-09-22 Post Count: 100802 |
18 lol still a long time secret forum
JOIN MY PRIMARY PEOPLE NOWWWWWWWWWWWWW |
|
jcs802Join Date: 2012-09-22 Post Count: 100802 |
19 lol still a long time secret forum
JOIN MY PRIMARY PEOPLE NOWWWWWWWWWWWWW |
|
jcs802Join Date: 2012-09-22 Post Count: 100802 |
20 lol still a long time secret forum
JOIN MY PRIMARY PEOPLE NOWWWWWWWWWWWWW |
|
jcs802Join Date: 2012-09-22 Post Count: 100802 |
21 lol still a long time secret forum
JOIN MY PRIMARY PEOPLE NOWWWWWWWWWWWWW |
|
jcs802Join Date: 2012-09-22 Post Count: 100802 |
22 lol still a long time secret forum
JOIN MY PRIMARY PEOPLE NOWWWWWWWWWWWWW |
|
jcs802Join Date: 2012-09-22 Post Count: 100802 |
23 lol still a long time secret forum
JOIN MY PRIMARY PEOPLE NOWWWWWWWWWWWWW |
|
jcs802Join Date: 2012-09-22 Post Count: 100802 |
24 lol still a long time secret forum
JOIN MY PRIMARY PEOPLE NOWWWWWWWWWWWWW |
|