Why does this work once but never again?

Hello Developers!
I am creating a Nuke System.
I have a gui and you click on it and a purchaseprompt pops up.
When the transaction suceeds, the nuke announcement pops up and the screen shakes and everyone dies.
However, when you repeat this process again, it doesn’t work!
Can someone help me? Thanks!

NukeButtonGui LocalScript:

local Id = 1250490905
local MPS = game:GetService("MarketplaceService")
local Player = game.Players.LocalPlayer

script.Parent.MouseButton1Click:Connect(function()
	MPS:PromptProductPurchase(Player, Id)
end)

Serverscript Script NukeSystem:

local market = game:GetService("MarketplaceService")
market.ProcessReceipt = function(ReciptInfo)
	if ReciptInfo.ProductId == 1250330224 then
		local player = game.Players:GetPlayerByUserId(ReciptInfo.PlayerId)
		game.ReplicatedStorage.RemoteEvent:FireAllClients(player)
		game.ReplicatedStorage.GUI:FireAllClients(player)
		local ShakeEvent = game.ReplicatedStorage:WaitForChild("ShakeEvent")
		ShakeEvent:FireAllClients(5)
		wait(5)
		for i,v in pairs(game.Players:GetPlayers()) do
			if v:IsA("Player") then
				local char = v.Character
				char.Humanoid.Health = 0
			end
		end
		wait(2)
		return Enum.ProductPurchaseDecision.PurchaseGranted
	end
end

Announcement GUI Local Script:

game.ReplicatedStorage.GUI.OnClientEvent:Connect(function()
	script.Parent.Parent.Enabled = true
	script.Parent.Text = "A"
	wait(0.1)
		script.Parent.Text = "A "
	wait(0.1)
		script.Parent.Text = "A N"
	wait(0.1)
		script.Parent.Text = "A NU"
	wait(0.1)
		script.Parent.Text = "A NUK"
	wait(0.1)
		script.Parent.Text = "A NUKE"
	wait(0.1)
		script.Parent.Text = "A NUKE "
	wait(0.1)
		script.Parent.Text = "A NUKE H"
	wait(0.1)
		script.Parent.Text = "A NUKE HA"
	wait(0.1)
		script.Parent.Text = "A NUKE HAS"
	wait(0.1)
	
		script.Parent.Text = "A NUKE HAS "
	wait(0.1)
		script.Parent.Text = "A NUKE HAS B"
	wait(0.1)
		script.Parent.Text = "A NUKE HAS BE"
	wait(0.1)
		script.Parent.Text = "A NUKE HAS BEE"
	wait(0.1)
		script.Parent.Text = "A NUKE HAS BEEN"
	wait(0.1)
		script.Parent.Text = "A NUKE HAS BEEN "
	wait(0.1)
	
		script.Parent.Text = "A NUKE HAS BEEN L"
	wait(0.1)
		script.Parent.Text = "A NUKE HAS BEEN LA"
	wait(0.1)
		script.Parent.Text = "A NUKE HAS BEEN LAU"
	wait(0.1)
		script.Parent.Text = "A NUKE HAS BEEN LAUN"
	wait(0.1)
		script.Parent.Text = "A NUKE HAS BEEN LAUNC"
	wait(0.1)
		script.Parent.Text = "A NUKE HAS BEEN LAUNCHE"
	wait(0.1)
		script.Parent.Text = "A NUKE HAS BEEN LAUNCHED"
	wait(0.1)
		script.Parent.Text = "A NUKE HAS BEEN LAUNCHED!"
		
		wait(3)
		script.Parent.Parent.Enabled = false
		
	
end)
1 Like

Hello try to use MarketplaceService.PromptPurchaseFinished
This it Will run every time a Payment is buyed / cancelled

how would i use it into a script?

Don’t use that bulky code, instead use:

nukeMessage = "A NUKE HAS BEEN LAUNCHED!"
for i = 1, #nukeMessage, 1 do
script.Parent.Text = string.sub(nukeMessage, 1, i)
wait(0.1)
end

This makes it more customizable. The string.sub here takes ‘nukemessage’ and displays the first character to character i, and adds 1 to i after every time it runs. Or, you can do

for i = 1, #nukeMessage, 1 do
script.Parent.Text = script.Parent.Text .. string.sub(nukeMessage, i, i)
end

I suggest you use the first one since it is less long.

3 Likes