I figured out what happens, my script seems to break ONCE I fire the bomb event. Are too many things happening and if so how could I simplify my code?
The main cause could be this painful script that I need to sort out:
local TweenService = game:GetService("TweenService")
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local Player = game:GetService("Players").LocalPlayer
local Character = Player.Character or Player.CharacterAdded:Wait()
local Lighting = game:GetService("Lighting")
local DeathwishMusic = Lighting:WaitForChild("DeathWish"):WaitForChild("DeathwishMusic")
function StartTimer(startValue, Type)
if Type == nil then return end
local tweenInfo = TweenInfo.new(startValue)
local Timer
if Type == "Death" then
Timer = script.DeathTimer:Clone()
local FX = script.Flash:Clone()
FX.Parent = Timer
FX.Enabled = true
else
Timer = script.CircleTimer:Clone()
end
Timer.Parent = script.Parent.TimerHolder
--print("timer started")
local TextLabel = Timer.Timer
for i, ui in pairs(Timer:GetDescendants()) do
if ui:IsA("ImageLabel") then
ui.ImageTransparency = 1
TweenService:Create(ui, TweenInfo.new(0.5), {ImageTransparency = 0}):Play()
end
end
local leftFrame = Timer:WaitForChild("LeftBG"):WaitForChild("LeftFrame")
local rightFrame = Timer:WaitForChild("RightBG"):WaitForChild("RightFrame")
local LColor = leftFrame:WaitForChild("LeftBG")
local RColor = rightFrame:WaitForChild("RightBG")
local ColorTween1 = TweenService:Create(LColor, TweenInfo.new(0.5), {ImageColor3 = Color3.fromRGB(255,255,255)})
local ColorTween2 = TweenService:Create(RColor, TweenInfo.new(0.5), {ImageColor3 = Color3.fromRGB(255,255,255)})
local numValue = Instance.new("NumberValue")
numValue.Changed:Connect(function()
local rightRot = math.clamp(numValue.Value - 180, -180, 0)
rightFrame.Rotation = rightRot
if numValue.Value <= 180 then
leftFrame.Visible = false
else
local leftRot = math.clamp(numValue.Value - 360, -180, 0)
leftFrame.Rotation = leftRot
leftFrame.Visible = true
end
end)
local function progressBar()
numValue.Value = 0
local progressTween = TweenService:Create(numValue, tweenInfo, {Value = 360})
progressTween:Play()
end
spawn(function()
progressBar()
for i= startValue, 0, -1 do
task.wait(Timer.TickAmount.Value)
Timer.Tick:Play()
TextLabel.Text = string.format("%02d", i)
if not Character:FindFirstChild("Bomb") then
for i, ui in pairs(Timer:GetDescendants()) do
if ui:IsA("ImageLabel") then
ui.ImageTransparency = 1
TweenService:Create(ui, TweenInfo.new(0.5), {ImageTransparency = 1}):Play()
end
task.wait(0.65)
Timer:Destroy()
end
break
end
end
end)
TextLabel:GetPropertyChangedSignal("Text"):Connect(function()
local Bomb = nil
local Signal = nil
local Emitter = nil
local Fast = nil
local Slow = nil
local Medium = nil
if Type == "Death" then
Bomb = Character.Bomb
Signal = Bomb.Handle.Signal
Emitter = Bomb.Handle.Beeper.ParticleEmitter
Fast = Signal.Fast
Slow = Signal.Slow
Medium = Signal.Medium
if TextLabel.Text == "20" then
script.DeathEnd:Play()
--
Fast.Enabled = true
Slow.Enabled = false
Medium.Enabled = false
--
Emitter.Rate = 15
TweenService:Create(DeathwishMusic, tweenInfo, {Volume = DeathwishMusic.Volume / 2}):Play()
task.wait(3)
script.Laugh:Play()
elseif TextLabel.Text < "60" then
Emitter.Rate = 10
--
Fast.Enabled = false
Slow.Enabled = false
Medium.Enabled = true
--
end
if TextLabel.Text == "00" or Character.Humanoid.Health == 0 then
Emitter.Rate = 20
script.Death:Play()
script.Fail:Play()
DeathwishMusic:Stop()
local Explosion = Instance.new("Explosion", Character.HumanoidRootPart)
game:GetService("Debris"):AddItem(Explosion, 1.25)
ReplicatedStorage.Remotes.Explosion:FireServer()
Character.Humanoid.Health = 0
for i, ui in pairs(Timer:GetDescendants()) do
if ui:IsA("ImageLabel") then
TweenService:Create(ui, TweenInfo.new(0.5), {ImageTransparency = 1}):Play()
elseif ui:IsA("TextLabel") then
TweenService:Create(ui, TweenInfo.new(0.5), {TextTransparency = 1}):Play()
end
end
end
end
if TextLabel.Text == "00" and Type == "Normal" then
ColorTween1:Play()
ColorTween2:Play()
ColorTween2.Completed:Wait()
local TextTween = TweenService:Create(TextLabel, TweenInfo.new(0.5), {TextTransparency = 1})
TextTween:Play()
for i, ui in pairs(Timer:GetDescendants()) do
if ui:IsA("ImageLabel") then
TweenService:Create(ui, TweenInfo.new(0.5), {ImageTransparency = 1}):Play()
end
end
TextTween.Completed:Wait()
Timer:Destroy()
end
end)
end
ReplicatedStorage.Remotes.TimerRE.Event:Connect(function(timerValue, Type)
if Type == "Death" then
StartTimer(268, "Death")
script.DeathStart:Play()
task.wait(0.5)
DeathwishMusic:Play()
task.wait(3.5)
script.Laugh:Play()
elseif Type == "Normal" then
StartTimer(timerValue, Type)
end
end)