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

How to make high level keycards to access low level doors?

Asked by 4 years ago

I need it so high level access can access low level doors.

script.Parent.Touched:Connect(function(Hit)
    local CheckIfCard = Hit.Parent:GetDescendants()

    for i,v in pairs(CheckIfCard) do
        if v:IsA("Tool") and v.Name == "Low Level Access" then
            script.Parent.CanCollide = false
            script.Parent.Transparency = 0.5
            wait(3)
            script.Parent.CanCollide = true
            script.Parent.Transparency = 0 
        end
    end
end)

2 answers

Log in to vote
0
Answered by 4 years ago

Please provide explanation with your answers. Simply posting code does not spread knowledge of integral scripting processes which helps people understand the logic and reasoning behind your answer.

I"m not sure if this will work, but try

local cards = {"Low Level Access", "Medium Level Access", etc}
script.Parent.Touched:Connect(function(Hit)
    local CheckIfCard = Hit.Parent:GetDescendants()

    for i,v in pairs(CheckIfCard) do
        if v:IsA("Tool") and v.Name == cards then
            script.Parent.CanCollide = false
            script.Parent.Transparency = 0.5
            wait(3)
            script.Parent.CanCollide = true
            script.Parent.Transparency = 0 
        end
    end
end)
Ad
Log in to vote
0
Answered by
KingDomas 153
4 years ago

Please provide explanation with your answers. Simply posting code does not spread knowledge of integral scripting processes which helps people understand the logic and reasoning behind your answer.

Create a module script and put it inside the keycard. Give it a variable level, for example:

keycardLevel = 2

and give the door a level in the main script,

doorLevel = 1

and inside the door, check if the card is equal to or higher than like so:

Variable = require(keycard.modulescriptname)
if Variable.keycardLevel >= doorLevel then

and open the door or whatever you were doing.

0
Sorry I'm still a beginner in scripting I don't really understand what to do. joshsharpe07 -1 — 4y

Answer this question