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)
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?
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
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)