Script not executing

Hello developers,
I have a problem which is I don’t know why. My script stops executing for some reason and no error in the output printed. The script runs well about 5 minutes before it stops executing. I really looking forward to any solutions.This is my script:

local char = game.ReplicatedStorage.Character:GetChildren()

for i , v in pairs(char)do
	v.HumanoidRootPart:WaitForChild("ProximityPrompt").Triggered:Connect(function(player)
		game.Workspace:WaitForChild("PizzaDeliver"):Destroy()
		game.Workspace.PromptInterract.Pizza.ProximityPrompt.Enabled = true
		player.leaderstats.Money.Value = player.leaderstats.Money.Value + 15
		v:Destroy()
		print("gogogagagogogaga")
	end)
end

Any response is very appreciated. Thank you :slight_smile: :slight_smile:

Using in pairs loop to listen to an event isn’t a great idea.

so what should I do instead((((()))))

Maybe just write this for every part. Also can you show me the explorer of the ReplicatedStorage.Character model?

So everything seems good. I’m not sure if for i,v… loop doesn’t have a limit of time it can run for. Maybe that is the reason why it stops working after few mins.

there are more of them that have similar problems like this… but every of them has (proximity prompt).Idk if that is the problem

I don’t think so. That’s probably a limit on something.

One of them is not using for loops wich is why Im very confused rn

this is the code if u want to check it

script.Parent.ProximityPrompt.Triggered:Connect(function(player)
	game.Workspace.AncientClone:ClearAllChildren()
	game.ReplicatedStorage.Remotes.SpawnAncienItem:FireClient(player)
	player.leaderstats.Money.Value = player.leaderstats.Money.Value + 150
	print("ok")
end)