Can you try this? Also add players and event variable.
local function explode()
bombPart.CanCollide = false
bombPart.BrickColor = red
task.wait(.6)
bombPart.CanCollide = true
click:Play()
bombPart.BrickColor = black
task.wait(.6)
click:Play()
bombPart.BrickColor = red
task.wait(.7)
click:Play()
bombPart.BrickColor = black
task.wait(.6)
click:Play()
bombPart.BrickColor = red
task.wait(.5)
click:Play()
bombPart.BrickColor = black
task.wait(.5)
click:Play()
bombPart.BrickColor = red
task.wait(.5)
click:Play()
bombPart.BrickColor = black
task.wait(.4)
click:Play()
bombPart.BrickColor = red
task.wait(.3)
click:Play()
bombPart.BrickColor = black
task.wait(.2)
click:Play()
bombPart.BrickColor = red
task.wait(.2)
click:Play()
bombPart.BrickColor = black
task.wait(.1)
click:Play()
bombPart.BrickColor = red
task.wait(.1)
click:Play()
bombPart.BrickColor = black
task.wait(.1)
click:Play()
bombPart.BrickColor = red
boom:Play()
explosion.Position = script.Parent.Position
explosion.Parent = script.Parent
explosion.Hit:Connect(function(basepart)
for i,v in pairs(Players:GetPlayers()) do
if basepart.Parent.Name == v.Name then
local Player = Players:GetPlayerFromCharacter(v)
event:FireClient(Player)
end
end
end)
Debris:AddItem(script.Parent, 1)
end
explode()
I actually found a fix to the issue sightly before you commented and forgot to close this here is the code if ur interested:
local function detect(part)
local plr = game.Players:GetPlayerFromCharacter(part.Parent)
local val_plr = tostring(val.Value)
local targetPlr = game.Players:FindFirstChild(val_plr)
if plr and targetPlr then
plr.Character.Humanoid:TakeDamage(100)
local humanoid = plr.Character:FindFirstChild("Humanoid")
if humanoid and humanoid.Health <= 1 then
event:FireClient(targetPlr, plr.Name)
end
end
end
explosion.Hit:Connect(detect)