Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

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

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)

5 comments

0

why do u want a keycard door with a function for no keycard ??

0

I would ask the same!

0

So it kills them.

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"

0

the name of the keycard is handle

3 answers

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?

1 comment

0

`what does hit mean

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

2 comments

0

It only lets them past if it is a specific tool not just any tool.

0

what does hit mean

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)

2 comments

0

when i die it still opens

0

when i die it still opens

This discussion is preserved as it was. New answers, comments, and votes are closed.