local clearance = { ["Card-Omni"] = true, ["Card-L5"] = true, ["Card-L4"] = true, ["Card-L3"] = true, ["Card-L2"] = false, ["Card-L1"] = false }
and
local Debounce = false script.Parent.Event.OnServerEvent:connect(function(Player) local Mag = (script.Parent.Center.Position-Player.Character.HumanoidRootPart.Position).magnitude if Mag <= script.Parent.Range.Value then if tool.Equipped:connect() and clearance[script.Parent.Name] == true then if not Debounce then Debounce = true
Everything below Debounce = true is text for the script that you don't need to look at. What I do want to focus on however is
if tool.Equipped:connect() and clearance[script.Parent.Name] == true then
I know this line is incorrect in all levels but I don't know the scripting on how to make tool.Equipped:connect(), into "if a tool from clearance is equipped on player" and clearance[script.Parent.Name] == true then, into "if tool equipped has clearance that's true." I don't know anything about scripting and I'm lucky I've made it this far. The original purpose of the script which makes you stand near a door and press "e" to open and close it does works except now I'm trying to make it into a keycard door where you equip your keycard and press "e" instead. Due to the fact that the line is incorrect entirely, the door cannot work as a keycard door.
You'd need to use a variable for it, toggling it when they equip and unequip it. An example of this would be:
local tool1 = workspace.something; -- some tools local tool2 = workspace.somethingelse; -- whatever local toolsEquipped = { -- make a list with tools being indexes and bool values tool1 = false; tool2 = false; -- start both as false because they're not equipped yet } for i,_ in pairs(toolsEquipped) do -- for each tool i.Equipped:Connect(function() -- when it's equipped set the value in the list to true toolsEquipped[i] = true; end) i.Unequipped:Connect(function() toolsEquipped[i] = false; -- when it's unequipped set the value in the list to false end) end
In this particular example, you can check whether something's currently equipped by checking toolsEquipped[referenceToTool]
, but you can always just set a normal variable and check something along the lines of tool1Equipped
.