Hey guys, I know you can use DialogChoiceSelected to get who's speaking to someone when they select a DialogChoice, but I want to know how to detect who's using a dialog (AKA: who triggered the InUse property to become true.)
I am trying to make an NPC that stops and keeps looking at the player who's talking to them until they either walk away or when the conversation ends, then goes back to what they were doing.
Here is my current script so far:
local region = require(game.ServerScriptService:WaitForChild("RegionScript"))
local paths = game.Lighting.Paths:GetChildren()
local npc = script.Parent
local hum = npc:WaitForChild("Humanoid")
local torso = npc:WaitForChild("Torso")
local head = npc:WaitForChild("Head")
local dialog = head:WaitForChild("ChatDialog")
while dialog.InUse ~= true do --When the NPC isn't being talked to.
local rand = math.random(1,#paths)
local randLoc = region:RandomiseLocation(paths[rand])
print(randLoc.X, randLoc.Y, randLoc.Z)
hum:MoveTo(randLoc)
local speed = hum.Running:wait()
if speed ~= 0 then repeat speed = hum.Running:wait() until speed == 0 end
wait(2)
end
while dialog.InUse == true do --When the NPC is being talked to.
hum.WalkSpeed = 0
--Need to do something here to find the player that's talking to the NPC.
torso.CFrame = CFrame.new(torso.Position, Vector3.new(Mouse.Hit.p.x, torso.Position.Y, Mouse.Hit.p.z)) --Stuck here as I need to find the player. Ignore Mouse.Hit as I was trying to find out how to turn a character towards someone.
end
Any help is appreciated, thanks!

1 comment
There's no way to get the player from the initial dialog activation.. unless you like put the npc in CurrentCamera and used localplayer or something but idk if that would even work