What i'm trying to do here is check if the players has the key that is needed to open a door.
Here's the code:
local KeyToched = script.Parent.KeyToched local Key = script.Parent.Key local NeededKey = Key.Value local Door = script.Parent.Parent.ExitDoor game.Players.PlayerAdded:Connect(function(plr) if plr.Backpack:FindFirstChild(NeededKey) or plr.Character:FindFirstChild(NeededKey) then Door.Touched:Connect(function(player) if player:FindFirstChild("Humanoid") then Door.Padlock.Anchored = false Door.Padlock.CanCollide = false end end) end end)
I don't know how to possibly fix it...
and the error is what the title says.
Try to use this: (Also add the script as a server script Inside of ServerScriptService)
local ToolName = "Key" game.Players.PlayerAdded:Connect(function(Player) Player.CharacterAdded:Connect(function(Character) if Player.Backpack:FindFirstChild(ToolName) then print("The user has a key!") else print("User has no key") end end) end)