the script needs to be executed only once
for _, DialogNPC in pairs(DialogNPCs:GetChildren()) do
if DialogNPC:IsA("Model") and DialogNPC:FindFirstChild("HumanoidRootPart") then
local humanoidRootPart = DialogNPC.HumanoidRootPart
humanoidRootPart.Touched:Connect(function(hit)
local character = hit.Parent
local player = Services.Players:GetPlayerFromCharacter(character)
if player then
RemoteEvents.Dialog:FireClient(player, DialogNPC.Name)
end
end)
end
end