I am currently making a facility inspired game and I am stuck on making a keybind door when a player has a certain tool in their backpack. I have it currently where doors have to be touched by a keycard, but I want it where its more simple with a simple keybind press when they have that tool. I haven’t found any videos on this topic because it might be to specific. Any ideas on where to start?
I think I will need to drop more information for this post to work. I’m not expecting full scripts, I just wanna know if there is any videos or any other dev forum posts. And if there is no other posts or videos, where I could get started.
I think it has something to do with
for a,b in pairs (Player:GetDescendants())do
if b.Name = "insert generic card name"then
door open script
end
so pretty much has something to do with values i think
local door = game.Workspace.Part -- Your door
local player = game.Players.LocalPlayer
for i,v in pairs(player:WaitForChild("Backpack"):GetDescendants()) do -- Loop through descendants of player's backpack
if v.Name == "Tool" then -- check to see if there's a certain tool name
print("TOOL")
v:FindFirstChild("Handle").Touched:Connect(function(hit) -- Getting the tool's handle and creating a touched event
if hit:IsA("Part") and hit.Name == "Door" then -- Check to see if the tool's handle touches something that's a "part" or the object's name is Door
hit.CanCollide = false -- Do whatever you want here...
end
end)
end
end
This is just a simple loop through the player’s backpack, finds a certain tool, if that’s tool handle has touched a certain object do something. If you want to make a keybind door, you’d probably use “UserInputService” and check to see if the player has clicked a key or ect.
The same concept would still apply, for checking the backpack for a certain tool.
In my opinion I think ContextActionService is more suitable for this situation.
Yeh, true. I would recommend using ContextActionService over UserInputService for this case scenario. I said UIS because it’s simpler to use and less advanced.
UserInputService is often unreliable when it comes to things like these. With ContextActionService, you don’t really have to use any boolean or debounce, you can just bind and unbind the action for the right time.