Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
1

Can someone help with a disappearing door?

Asked by
Scerzy 85
10 years ago

Well I know it would be easy to make a door disappear and reappear by using an onTouch function and setting it's can-collide to be false and its transparency to fade to 1. But I need help. Is there any way that I can have a tool in my starterpack where if I click, the door dissappears, but if I click again, the door reappears? I already know how to do the script for the dissappearing part and the reappearing part, I just need someone to point me in the right direction.

Also, if this is not possible, I can settle for a button where if I click, it fades and if I click again, it reappears. I just don't know the function for it.

This is my fading script using an onTouch function. Hope that helps somehow.

01Brick = script.Parent
02 
03fading = false
04 
05Brick.Touched:connect(function(part)
06 
07    if not fading then
08 
09        fading = true
10 
11        for i = 1, 10 do
12 
13            Brick.Transparency = Brick.Transparency + .1
14 
15            wait(.1)
View all 27 lines...
01local Brick = script.Parent
02 
03 
04 
05Brick.Changed:connect(function(prop)
06 
07    if prop == "Transparency" then
08 
09        if Brick.Transparency >= 1 then
10 
11            Brick.CanCollide = false
12 
13        else
14 
15            Brick.CanCollide = true
View all 21 lines...

1 answer

Log in to vote
0
Answered by
yumtaste 476 Moderation Voter
10 years ago

You can listen for the Equipped event of a tool, get the mouse, then listen for a click, check if the door was clicked on, then take appropriate action. Here, I'll give you an example:

1local door = workspace:FindFirstChild("Door") --change this to the location of the door
2 
3script.Parent.Equipped:connect(function(mouse)
4if mouse.Target then
5if mouse.Target == door then
6--take appropriate action here
7end
8end
9end)
0
Thank you, this seems like it'd work like a charm. However, one quick question. Where would this script be places? In other words, what would its parent be? Scerzy 85 — 10y
0
It would be a child of a Tool. If I answered your question, please mark it as accepted and upvote! yumtaste 476 — 10y
Ad

Answer this question