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

How? do i make a keycard door with 2 functions for no keycard and keycard

Asked by 4 years ago
Edited 4 years ago

how do you make 2 different functions, one for if you dont have a keycard, and one if you do

how do i make a key card a function happens whether u have a keycard or not (dont add anything under the function eg: script.parent.touched.cancollide = false. just how to activate the script)

the key card sensor is called Door and the keycard is called Handle

also add where to put the script(which part)

0
why do u want a keycard door with a function for no keycard ?? ItsBasicallyDenis -3 — 4y
0
I would ask the same! P3tray 0 — 4y
0
So it kills them. Geobloxia 251 — 4y
0
Call the Keycard tool "Keycard" instead of handle. Are you talking about the name of the tool or handle? Because every handle for a tool is called "Handle" Geobloxia 251 — 4y
0
the name of the keycard is handle IckyInvin5ible7 -70 — 4y

3 answers

Log in to vote
0
Answered by
P3tray 0
4 years ago

I don't quite get what your trying to ask as your English skill are absolutly terrible! I have interpreted it as this:

function noKey(player)
    print(player, "Has no Keycard!")
end

%CONNECT CODE%

if hit.Parent:FindFirstChild("Handle") == true then
    %OPEN DOOR%
else
    noKey(hit)
end

Could you be more specific to as what you would like help with?

0
`what does hit mean IckyInvin5ible7 -70 — 4y
Ad
Log in to vote
0
Answered by 4 years ago
Edited 4 years ago

You can't do

hit.Parent:FindFirstChild("Handle") = true

You could try

if hit.Parent:FindFirstChildOfClass("Tool").Name = "Handle" then

and for the other one

else 
  Put your code here
0
It only lets them past if it is a specific tool not just any tool. Geobloxia 251 — 4y
0
what does hit mean IckyInvin5ible7 -70 — 4y
Log in to vote
0
Answered by
Geobloxia 251 Moderation Voter
4 years ago
Edited 4 years ago
local time = 3 -- time the player has before door closes
script.Parent.Touched:Connect(function(hit)
    if hit.Parent:FindFirstChild("Keycard") then
    -- player has to be holding a tool called "Keycard"
    -- the handle for any tool is called "Handle"
    -- and so it is better if you get the tool name
        script.Parent.CanCollide = false
        script.Parent.Transparency = 0.5
        -- changes properties so play can go through
        wait(time) -- waits value of time
        script.Parent.CanCollide = true
        script.Parent.Transparency = 0
    elseif not hit.Parent:FindFirstChild("Keycard") and hit.Parent:FindFirstChild("Humanoid") then
        hit.Parent:BreakJoints()
    end
end)

But if you really want to call it Handle:

local time = 3 -- time the player has before door closes
script.Parent.Touched:Connect(function(hit)
    if hit.Parent:FindFirstChild("Handle") then
    -- player has to be holding a tool called "Keycard"
    -- the handle for any tool is called "Handle"
    -- and so it is better if you get the tool name
    -- make sure it is called keycard
        script.Parent.CanCollide = false
        script.Parent.Transparency = 0.5
        -- changes properties so play can go through
        wait(time) -- waits value of time
        script.Parent.CanCollide = true
        script.Parent.Transparency = 0
    elseif not hit.Parent:FindFirstChild("Handle") and hit.Parent:FindFirstChild("Humanoid") then
        hit.Parent:BreakJoints()
    end
end)
0
when i die it still opens IckyInvin5ible7 -70 — 4y
0
when i die it still opens IckyInvin5ible7 -70 — 4y

Answer this question