Hello!
(Heads up, I’m bad at coding.)
I am trying to code a door where if an NPC were to touch it, it would automatically open. However, if the player wants to get inside they have to click it, so the If Touched statement won’t trigger if the player would to touch it:
local door = script.Parent
local Player = game.Players:GetPlayers("Player")
door.Touched:Connect(function(char)
if char.Parent == not Player.Character then
-- Door Open Script
end
end
door.ClickDetector.MouseClick:Connect(function() -- If Player Then
-- Door Open Script
end)
The issue is that when I set it to “not Player.Character”, the player nor NPC’s can open the door. But if I set it to the player only, both the player and NPC’s can open it (I hope this all makes sense). How can I fix this?