About 3 days ago I created a door that opens by clicking on it. But I'm looking for a way to make the door open only for players who have a key in their hotbar (You don't have to have the key in your hand, you only need to have it in the hotbar). Can someone help me?
ClickDetector Script:
function onClicked() if script.Parent.Parent.Active.Value == false then script.Parent.Parent.Active.Value = true script.Parent.Sound.Playing = true end end script.Parent.ClickDetector.MouseClick:connect(onClicked)
If you need the door script let me know.
First you need to get the player clicking the part by doing onClicked(player), then checking if the key is in the player's backpack.
function onClicked(player) if player.Backpack:FindFirstChild("EnterTheKeyNameHere") then if script.Parent.Parent.Active.Value == false then script.Parent.Parent.Active.Value = true script.Parent.Sound.Playing = true end end end script.Parent.ClickDetector.MouseClick:connect(onClicked)