So the nuke is perfectly functional and no errors in the first time of launching but in the second time of launching the events are all fired again except the camera shake event it just doesn’t work anymore in the second try, Any idea on how to fix that? I tried disconnecting the event but keeps showing an error even if I put a wait function
Script:
local DPID1 = 1299613952
local CameraShake = RS.Nuke.CameraShake
local Explosion = RS.Nuke.Explosion
local AnimatedTextEvent = RS.Nuke.AnimatedText
local ChatText = RS.Nuke.ChatText
local Siren = RS.Nuke.Siren
local End = RS.Nuke.End
local function KillAll()
for i, v in pairs(game.Players:GetChildren()) do
v.Character.Humanoid:TakeDamage(100)
end
end
MPS.ProcessReceipt = function(receiptinfo)
local player = game.Players:GetPlayerByUserId(receiptinfo.PlayerId)
if not player then
return Enum.ProductPurchaseDecision.NotProcessedYet
end
if receiptinfo.ProductId == DPID1 then
game.Workspace.Nuke.NukePrompt.ProximityPrompt.Enabled = false
CameraShake:FireAllClients()
Siren:FireAllClients()
AnimatedTextEvent:FireAllClients(player)
ChatText:FireAllClients(player)
wait(15)
Explosion:FireAllClients()
KillAll()
wait(5)
End:FireAllClients()
game.Workspace.Nuke.NukePrompt.ProximityPrompt.Enabled = true
(Not the full script because there are other things besides nuke)
local Player = game.Players.LocalPlayer
local Char = Player.Character or Player.CharacterAdded:Wait()
local NukeFolder = game.Workspace.Nuke
local NukePrompt = NukeFolder.NukePrompt.ProximityPrompt
local MPS = game:GetService("MarketplaceService")
local DPID = 1299613952
local SirenSound = script.Siren
local ExplosionSound = script.Explosion
local Rs = game:GetService("ReplicatedStorage")
local Explosion = Rs.Nuke.Explosion
local CameraShake = Rs.Nuke.CameraShake
local AnimatedTextEvent = Rs.Nuke.AnimatedText
local Siren = Rs.Nuke.Siren
local ChatText = Rs.Nuke.ChatText
local End = Rs.Nuke.End
local AnimatedTextEventLabel = Player.PlayerGui:WaitForChild("Nuke").TextLabel
NukePrompt.Triggered:Connect(function()
MPS:PromptProductPurchase(Player, DPID)
end)
local function AnimatedText(object, text)
for i = 1, #text, 1 do
object.Text = string.sub(text, 1, i)
wait(0.05)
end
end
--Siren
Siren.OnClientEvent:Connect(function()
SirenSound:Play()
end)
--CameraShake
CameraShake.OnClientEvent:Connect(function()
local function CS(time)
local ST = tick()
while true do
if tick() - ST >= time then break end
local X = math.random(-1000, 1000) / 1000
local Y = math.random(-1000, 1000) / 1000
local Z = math.random(-1000, 1000) / 1000
Char:WaitForChild("Humanoid").CameraOffset = Vector3.new(X, Y, Z)
workspace.CurrentCamera.CFrame *= CFrame.Angles(X / 300, Y / 300, Z / 300)
wait()
end
Char:WaitForChild("Humanoid").CameraOffset = Vector3.new(0, 0, 0)
end
CS(20)
end)
--AnimatedText
AnimatedTextEvent.OnClientEvent:Connect(function(player)
AnimatedTextEventLabel.Visible = true
AnimatedTextEventLabel.TextTransparency = 0
AnimatedText(AnimatedTextEventLabel, player.Name.." Has launched a nuke!!!")
end)
--ChatText
ChatText.OnClientEvent:Connect(function(player)
game.StarterGui:SetCore("ChatMakeSystemMessage",
{
Text = "[Server]: "..player.Name.." Has launched a nuke!!!",
Size = 20,
Color = Color3.new(1, 0, 0),
Font = Enum.Font.DenkOne
}
)
end)
--Explosion
Explosion.OnClientEvent:Connect(function()
ExplosionSound:Play()
local lightning = game.Lighting
lightning.ExposureCompensation = 3
lightning.Brightness = 10
end)
End.OnClientEvent:Connect(function()
for i = 3, 0, -0.1 do
game.Lighting.ExposureCompensation = i
wait(0.01)
end
for i = 10, 3, -0.1 do
game.Lighting.Brightness = i
wait(0.01)
end
for i = 0, 1, 0.1 do
AnimatedTextEventLabel.TextTransparency = i
wait(0.01)
end
AnimatedTextEventLabel.Text = ""
SirenSound:Stop()
end)
(Full Script)