Ok I'm new to scripting and I can't figure out how to make it where it checks for the key(or my tool) BUT when its equipped. I have it working for when its in my backpack it teleports me but I cant equipped the key when I want to tp
sorry if it looks like stupid code I'm just new
line 26 is where I try to make it for when the key is equipped it teleports me when I click on e on the door
player = game:GetService("Players")
local Tp = workspace.Backrooms
local Target = "Key"
local Proximity = script.Parent
local Door = script.Parent.Parent.Parent.Door
script.Parent.Triggered:Connect(function(player)
local Backpack = player:WaitForChild("Backpack")
if Backpack:FindFirstChild("Key") then
local Key = Backpack:FindFirstChild("Key")
game.ReplicatedStorage.GuiAnimate2:FireClient(player)
wait(5)
player.Character.HumanoidRootPart.CFrame = CFrame.new(Tp.Position)
else
print("No Working Or Doesn't have key")
end
end)
game.Players.PlayerAdded:Connect(function(plr)
script.Parent.Triggered:Connect(function(player)
local IsInBackpack = false
local Key = player.Backpack:FindFirstChild()
if Key or Key.Equipped then
IsInBackpack = true
game.ReplicatedStorage.GuiAnimate2:FireClient(player)
wait(5)
player.Character.HumanoidRootPart.CFrame = CFrame.new(Tp.Position)
end
end)
end)

1 comment
Thanks that worked