For loop stopping after player respawn

Hi, I’m trying to make a taco rain script but for some reason whenever the player dies and respawns the rain stops for no reason.

It doesn’t even continue to the line after the loop.

I would’ve used remote event but I don’t want hackers being able to summon 100 of these rains at once and crashing the server

(Can’t upload video cus it won’t let me)

local marketplace = game:GetService("MarketplaceService")
local plr = script.Parent.Parent.Parent
local gamepass = 1271828785

script.Parent.ImageButton.MouseButton1Click:Connect(function()

	marketplace:PromptPurchase(plr,gamepass)	

end)


marketplace.PromptPurchaseFinished:Connect(function(plr,gamepass,purchased)
	
game.Workspace.TACO:Play()
	
for i = 1, 1500 do
		
		
		local taco = game.ReplicatedStorage.Taco:Clone()
		taco.Parent = game.Workspace
		taco.Position = Vector3.new(math.random(-250,250),100,math.random(-250,250))
		wait()
		
end

game.Workspace.TACO:Stop()
for i,v in pairs(game.Workspace:GetChildren()) do
	if v.Name == "Taco" or v.Name == "TacoModel" then
		v:Destroy()
	end
	end
end)

Well this script is probably in PlayerGui, so your script is getting destroyed after the player dies. You want to use a RemoteEvent, just make sure you are asking the server to rain, not telling it, to prevent hacking.

what is the parent of the script?, if it’s a giu make sure ResetOnSpawn is false