Here’s the code if you wanna take a look, I just destroy the tweens after their completed events have fired.
if not workspace:GetAttribute("NukeInProgress") then
workspace:SetAttribute("NukeInProgress", true)
Player.leaderstats[" Spent"].Value += 600
for i = 0.5, 0, -0.001 do
MainMusic.Volume = i
task.wait(0.01)
end
for _, player in Players:GetPlayers() do
player.PlayerGui.NukeGui.PurchasedText.Text = Player.Name .. " Purchased A Nuke!"
player.PlayerGui.NukeGui.PurchasedText.Visible = true
end
NukeSiren:Play()
local Nuke = workspace.NukeModel
local Fire = Nuke.FirePart.Attachment.Fire
local CFValue = Instance.new("CFrameValue")
CFValue.Value = Nuke:GetPivot()
CFValue:GetPropertyChangedSignal("Value"):Connect(function()
Nuke:PivotTo(CFValue.Value)
end)
local TweenTable = {
Value = CFValue.Value * CFrame.new(1000,0,0)
}
local Tween = TweenService:Create(CFValue, TweenInfo.new(10, Enum.EasingStyle.Linear), TweenTable)
for i = 10, 0, -1 do
for _, player in Players:GetPlayers() do
player.PlayerGui.NukeGui.RedText.Visible = true
player.PlayerGui.NukeGui.RedText.Text = "Launching in: "..i
NukeLaunching:Play()
end
task.wait(1)
end
for _, player in Players:GetPlayers() do
player.PlayerGui.NukeGui.RedText.Visible = false
end
NukeLaunched:Play()
Tween:Play()
Fire.Enabled = true
Tween.Completed:Connect(function()
local NewCFValue = Instance.new("CFrameValue")
Nuke:PivotTo(CFrame.new(0,1000,0) * CFrame.Angles(0,0,math.rad(270)))
NewCFValue.Value = Nuke:GetPivot()
NewCFValue:GetPropertyChangedSignal("Value"):Connect(function()
Nuke:PivotTo(NewCFValue.Value)
end)
local NewTweenTable = {
Value = CFrame.new(0,0,0) * CFrame.Angles(0,0,math.rad(270))
}
local NewTween = TweenService:Create(NewCFValue, TweenInfo.new(9, Enum.EasingStyle.Linear), NewTweenTable)
NukeSiren:Stop()
NukeLanding:Play()
NewTween:Play()
CFValue:Destroy()
Tween:Destroy()
NewTween.Completed:Connect(function()
NukeLanding:Stop()
NukeExplosion:Play()
local NukePart = ServerStorage.NukePart:Clone()
NukePart.Position = Nuke.NukePartHolder.Position
NukePart.Parent = workspace
Nuke:Destroy()
local NukeProperties = {
Size = Vector3.new(800,800,800)
}
local NukeAnimation = TweenService:Create(NukePart, TweenInfo.new(5, Enum.EasingStyle.Linear), NukeProperties)
NukeAnimation:Play()
NukeAnimation.Completed:Connect(function()
for i = 5, 0, -1 do
for _, player in Players:GetPlayers() do
NukeLaunching:Play()
player.PlayerGui.NukeGui.RedText.Visible = true
player.PlayerGui.NukeGui.RedText.Text = "Map Refreshing In: "..i
end
task.wait(1)
end
NukePart:Destroy()
for _, player in Players:GetPlayers() do
player.PlayerGui.NukeGui.PurchasedText.Visible = false
player.PlayerGui.NukeGui.RedText.Visible = false
end
local NewNuke = ServerStorage.NukeModel:Clone()
NewNuke.Parent = workspace
for i = 0, 0.2, 0.001 do
MainMusic.Volume = i
task.wait(0.01)
end
NukeAnimation:Destroy()
workspace:SetAttribute("NukeInProgress", false)
end)
NewCFValue:Destroy()
NewTween:Destroy()
end)
end)
else
local config: BanConfigType = {
UserIds = {Player.UserId},
Duration = -1,
ApplyToUniverse = true,
DisplayReason = "Exploiting",
PrivateReason = "Exploiting"
}
Players:BanAsync(config)
end
return Enum.ProductPurchaseDecision.PurchaseGranted
And the ban stuff is just a cooldown I made to stop players from purchasing a nuke while one is currently happening, of course exploiters can just prompt themselves to buy it with code. Which is why I have this system to check that.