local ToolName = workspace.Keycard door = script.parent
game.Players.PlayerAdded:Connect(function(Player) Player.CharacterAdded:Connect(function(Character) if Player.Backpack:FindFirstChild(ToolName) then print("Player has tool in backpack!") else print("Player does not have tool in backpack!") end end)
end)
it works but how do i make it work if the player touches the door
Don't use the guys above me, his has some problems.
Edit: Don't worry about the tabs. The site has some problems with the formation of code.
local ToolName = game.ServerStorage.Keycard.Name local door = script.parent door.Touched:Connect(function(hit) if hit.Parent:FindFirstChild("Humanoid") then local Player = game.Players:GetPlayerFromCharacter(hit.Parent) if Player.Backpack:FindFirstChild(ToolName) then print("Player has tool in backpack!") else print("Player does not have tool in backpack!") end end end)
Next time please use the code boxes please. Thank you! Paste this in to your door part.
Some security stuff
Put the Keycard in serverstorage so it cannot be hacked / stolen
local ToolName = game.ServerStorage.Keycard.Name local door = script.parent door.Touched:Connect(function(Player) if Player.Backpack:FindFirstChild(ToolName) then print("Player has tool in backpack!") else print("Player does not have tool in backpack!") end end)