My problem is that with my keycard code I cannot detect if the keycard is equipped or not, only if it is in the player’s backpack.
I have created a door system that to unlock it you must 1. Have the keycard in your inventory 2. you must use the proximity prompt *with it equipped.
My problem is I cannot change the value to see if the player is equipped (holding) the tool.
Code:
local player = game.Players.LocalPlayer
local Granted = game.Workspace.Sounds["Access Granted [Half-Life 1]"]
local Decline = game.Workspace.Sounds["Access Denied [Half-Life 1]"]
local DoorPart = game.Workspace.DoorTest
local NeonPart = game.Workspace.Keypad
local Prompt = NeonPart.ProximityPrompt
local TweenService = game:GetService("TweenService")
local tweenInfo1 = TweenInfo.new(1.5, Enum.EasingStyle.Cubic, Enum.EasingDirection.In)
local tween1 = TweenService:Create(DoorPart, tweenInfo1, {Position=Vector3.new(-115.558, 10.372, -147.987)})
local tween2 = TweenService:Create(DoorPart, tweenInfo1, {Position=Vector3.new(-115.558, 3.572, -147.987)})
Prompt.Triggered:Connect(function(player)
local Tool = player.Backpack:FindFirstChild("KeyCardLVL1") or player.Character:FindFirstChild("KeyCardLVL1")
if Tool.Activated then -- I've tried equipped as well but it just results in an error.
print("Keycard is yes")
Decline.Playing = false
Granted.Playing = true
NeonPart.BrickColor = BrickColor.new(0.266667, 1, 0)
tween1:Play()
Prompt.Enabled = false
end
end)
Prompt.Triggered:Connect(function()
print("No keycard")
Decline.Playing = true
end)