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

How to make a door that only opens with a item u named and picked it up and insert it? [closed]

Asked by 4 years ago

like im making a door but i needa thing i can insert a model or a block into it and the item you put into it if its the right named block or the right thing it can let you gopast but if you hold a diffrent one then it takes away your item also the right key/block/mdel/block but it has to be a script to insert it into A part

0
so your trying to make a key door and if the name of the tool the character is holding is not equal to the keys name then it get's deleted thebananashetoldyou 31 — 4y

Closed as Not Constructive by youtubemasterWOW and JesseSong

This question has been closed because it is not constructive to others or the asker. Most commonly, questions that are requests with no attempt from the asker to solve their problem will fall into this category.

Why was this question closed?

1 answer

Log in to vote
0
Answered by 4 years ago

first you need to put a script into the door next in the script you have to use the Touched event because something like a key is used to touch it. After you use script.Parent.Touched in the first line and follow Touched with :Connect(function()) to connect the event to a function

it should look like this

script.Parent.Touched:Connect(function(hit)
-- Code that happend's when it's touched goes here
end)

you put hit in the parathesis because that is the argument something touches the door and u use hit to reference the thing touching it.Also it's name doesn't have to be hit it can be anything so you can rename it something like key

next in the starter pack you make a tool and rename the tool something like "Key"

after you go back to the script and and use a if statement to say

if hit.Parent.Name = "Key" then

--[[ code that happends if hit is Named "key" you should make the door allow people to go thought in this code block use CanCollide and change its Transparency so they can talk thought and they know it's open--]]

end

the reason we say hit.Parent instead of hit is because the tool isn't the thing touching the door it's the handle that is

and yeah that's how u make a door

Ad