How to add delay

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

It already is executed once? (from what you posted)
Unless you mean the touched event in which case you can use :Once() instead of :Connect() or disconnect the event.

2 Likes

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.