I am trying to make an explosion where the player is, and it is custom shaped. But it won't do damage. Here is my code:
local function explode(part,givencolor,radius)
local explosion = Instance.new("Part", part.Parent)
local explosionSounds = {
"rbxassetid://144699494",
"rbxassetid://2648563122",
"rbxassetid://3154829820",
"rbxassetid://1197889183"
}
explosion.Anchored = true
explosion.Position = part.Position
explosion.Shape = Enum.PartType.Ball
explosion.Material = Enum.Material.Neon
explosion.CanCollide = false
explosion.Size = Vector3.new(1,1,1)
explosion.Color = givencolor
explosion.Name = "Explosion"
local exSound = Instance.new("Sound",explosion)
exSound.SoundId = explosionSounds[math.random(#explosionSounds)]
exSound.Volume = 5
exSound:Play()
for i=1, radius, 1 do
explosion.Size = explosion.Size + Vector3.new(1,1,1)
explosion.Transparency = explosion.Transparency + 1/radius
explosion.Touched:Connect(function(hit)
local humanoid = hit.Parent:FindFirstChild("Humanoid")
if humanoid and hit.Parent ~= explosion.Parent then
humanoid:TakeDamage(5)
end
end)
wait()
end
explosion:Destroy()
end
Can anyone help me (pls don't just comment, i need ANSWERS.)

1 comment