I know some basic idea of true and false, but how would I detect if a player is in the NPC or not? I want it so that if the player press e and he is in the NPC, he goes back in
heres my script:
local Character = script.Parent
local Npc = game.Workspace.Npc
local camera = workspace.CurrentCamera
UIS.InputBegan:Connect(function(Key, Chatted)
if Chatted then
return
end
if Key.KeyCode == Enum.KeyCode.E then
local Player = game.Players.LocalPlayer
camera.CameraSubject = Npc.Humanoid
Player.Character = Npc
end
end)
Referencing from the OP, I think he’s wanting to check if the CameraSubject is focused on the NPC’s POV? Either that or a check for the NPC's Parent
You could just check if the CameraSubject is equal to the Humanoid using a conditional statement possibly? You’d need to detect some change though for when the CameraSubject changes it’s view:
local Character = script.Parent
local Npc = game.Workspace.Npc
local camera = workspace.CurrentCamera
UIS.InputBegan:Connect(function(Key, Chatted)
if Chatted then
return
end
if Key.KeyCode == Enum.KeyCode.E then
local Player = game.Players.LocalPlayer
camera.CameraSubject = Npc.Humanoid
Player.Character = Npc
end
camera:GetPropertyChangedSignal("CameraSubject"):Connect(function()
if camera.CameraSubject ~= Npc.Humanoid then
--Implement your code here
end
end)
end)