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

How to make a Keycard and Door Function?

Asked by 8 years ago

I want to make it so when you touch a door with a certain tool "Key Card" The door will go slightly transparent and it will go Noncollide, I need it to find what hit the door in Ontouch function and then if it comes back as Key Card "Key Card" nil then game.Workspace.Door.Transparency= 5 game.Workspace.Door.Noncollide= False

Idk how to fully script I just copy scripts from this website and use them until I can fully remember them, But if you could give me a script and then teach me it would sure help me c;

2 answers

Log in to vote
0
Answered by 8 years ago
Edited 7 years ago

I have a keycard model you can use for free here: www.roblox.com/item.aspx?seoname=Key-Card-Door&id=495619656

The script for the door is here (and in the free model) :

--By glowingglow


Door = script.Parent --Where The Door Part Is  
Opentime = 1 -- How Long The Door Is Open For
Debounce = false --Stops The Door Being Opened More Than Once AT One Time

script.Parent.Touched:connect(function(Part)
    if Debounce ~= true then --Make Sure That The Door Is Not Already Open
        Debounce = true --Sets The Variable Debounce To True So The Script Knows Not To Open It Again. 
        local keycard = Part:FindFirstChild("keycard")--Find The BoolValue keycard (in the tool handle)
        if keycard ~= nil and keycard.Value == true then --Check That keyvale exists and its set to true
            Door.Transparency = 1 --Set Door Transparency to 1
            Door.CanCollide = false --Set CanCollide to false 
            wait(Opentime) --Wait For How Long The Variable Opentime Is Set For
            Door.CanCollide = true --Set CanCollide to false
            Door.Transparency = 0 --Set Door Transparency to 0
        end --Ends The If Statement
        Debounce = false --Set Debounce To False So The Door Can Be Opened Again.
    end --Ends The If Statement 
end) --Ends The Function

Please remember that this is a help site, not a request site. I only answered because I happened to be making a keycard door.

Ad
Log in to vote
0
Answered by 5 years ago

place this script in the door

script.Parent.Touched:Connect(function(hit)
if hit.Parent == "Keycard" then
script.Parent.Transparency = 0.5
script.Parent.CanCollide = false
wait(2)
script.Parent.Transparency = 1
script.Parent.CanCollide = true
end
end)
0
Then make a tool called Keycard spelled exactly. DogHouseForMe 0 — 5y

Answer this question