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
How to make a door that only opens with a item u named and picked it up and insert it?
1 answer
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
This discussion is preserved as it was. New answers, comments, and votes are closed.

1 comment
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