I've made a detector script which sees if a player has a tool in their backpack called "LavaKey" and then if so opens a door by making it invisible and then waits 8 seconds and closes it. The issue is I cant seem to get the line that sees if the key is in the backpack correct and when I run the game and step on the detector I get an error on line 10 saying that "Backpack is not a valid member of Model" but then after that I get no more errors. (That error may be referring to the door thats on the detector or something but it doesnt have a humanoid. Anyone know what I need to fix? Thx.
local detector = script.Parent local door = game.Workspace.LavaDoor DB = true detector.Touched:Connect(function(hit) if DB == true then DB = false if hit.Parent:FindFirstChild('Humanoid') then local hum = hit.Parent:FindFirstChild('Humanoid') if hit.Parent.Backpack:FindFirstChild("LavaKey") then--here door.Transparency = 1 door.CanCollide = false wait(8) door.Transparency = 0 door.CanCollide = true elseif not hit.Parent.Backpack:FindFirstChild("LavaKey") then hum:TakeDamage(20) end wait(2) DB = true end end end)
The backpack is not in the character in workspace, which is where you are looking, you need to access the players backpack in the game.players, which can be done by
game:GetService:("players")
Sorry for not writing out a script that will get the player exactly how you need it to but i think this should answer your question if you're aware on how to get players from the player folder, Let me know!