local BombFolder = game.ReplicatedStorage:WaitForChild("Bomb")
local Remote2 = BombFolder.Remote.BombThrow
local Debris = game:GetService("Debris")
local Animation = BombFolder.Animations.BombThrow
local Damage = 20
local ExplosionSound = BombFolder.Sounds.Explosion
local TweenService = game:GetService("TweenService")
local Informatic = TweenInfo.new(
0.75,
Enum.EasingStyle.Sine,
Enum.EasingDirection.In,
0,
false,
0
)
local Propreties = {Size = Vector3.new(5.649, 5.649, 5.649)}
Remote2.OnServerEvent:Connect(function(plr)
local RedExplosion = BombFolder.Meshes.RedExplosion:Clone()
local Character = plr.Character or plr.CharacterAdded:Wait()
local HumanoidRootPart = Character:FindFirstChild("HumanoidRootPart")
local Humanoid = Character:FindFirstChild("Humanoid")
local AnimationTrack = Humanoid:LoadAnimation(Animation)
AnimationTrack:Play()
local RedExplosionDescendents = {
A0 = BombFolder.Meshes.RedExplosion.A:Clone(),
A1 = BombFolder.Meshes.RedExplosion.A1:Clone(),
A2 = BombFolder.Meshes.RedExplosion.A2:Clone(),
A3 = BombFolder.Meshes.RedExplosion.A3:Clone(),
}
local MiniBomb = BombFolder.Meshes.MiniBomb:clone()
local TweenTrack1 = TweenService:Create(RedExplosionDescendents.A0,Informatic,Propreties)
local TweenTrack2 = TweenService:Create(RedExplosionDescendents.A1,Informatic,Propreties)
local TweenTrack3 = TweenService:Create(RedExplosionDescendents.A2,Informatic,Propreties)
local TweenTrack4 = TweenService:Create(RedExplosionDescendents.A3,Informatic,Propreties)
MiniBomb.Parent = workspace
MiniBomb.CFrame = HumanoidRootPart.CFrame
local BodyV = Instance.new("BodyVelocity", MiniBomb)
BodyV.MaxForce = Vector3.new(math.huge,math.huge,math.huge)
BodyV.Velocity = HumanoidRootPart.CFrame.LookVector * 100
local debounce = false
MiniBomb.Touched:Connect(function(hit)
if hit.Parent == plr.Character then return end
if not debounce then
debounce = true
if hit.Parent:FindFirstChild("Humanoid") and hit.Parent:FindFirstChild("HumanoidRootPart") then
task.wait(0.5)
hit.Parent.Humanoid:TakeDamage(Damage)
RedExplosionDescendents.Parent = workspace
Debris:AddItem(RedExplosionDescendents.AO,1)
Debris:AddItem(RedExplosionDescendents.A1,1)
Debris:AddItem(RedExplosionDescendents.A2,1)
Debris:AddItem(RedExplosionDescendents.A3,1)
RedExplosionDescendents.A0.Position = hit.Parent.HumanoidRootPart.Position
RedExplosionDescendents.A1.Position = hit.Parent.HumanoidRootPart.Position
RedExplosionDescendents.A2.Position = hit.Parent.HumanoidRootPart.Position
RedExplosionDescendents.A3.Position = hit.Parent.HumanoidRootPart.Position
TweenTrack1:Play()
TweenTrack2:Play()
TweenTrack3:Play()
TweenTrack4:Play()
ExplosionSound:play()
MiniBomb:Destroy()
end
debounce = false
end
end)
end)
I added a debounce so that the script doesn’t over fire (if it over fires it could cause issues like killing the player because it’s applied over 200 more times than expected, and the player being removed while this is processing could cause the parts to disappear unexpectedly) and i added another condition to your if statement
That’d likely be because there was neither a humanoid or a humanoidrootpart found on anything that was touched, do you have a video example that you can provide?
An alternative you could change these lines to get some more information
debounce = true
if hit.Parent:FindFirstChild("Humanoid") and hit.Parent:FindFirstChild("HumanoidRootPart") then
Change with
debounce = true
print("----------New Touch process---------------"
print(hit.Name)
print(hit.Parent.Name)
print(hit.Parent:FindFirstChild("HumanoidRootPart"))
if hit.Parent:FindFirstChild("Humanoid") and hit.Parent:FindFirstChild("HumanoidRootPart") then
with that it’ll output a bit of information, but it’ll tell you what it hit, and if it had a root part.
The hit.Name output could assist with determining why this isn’t processing as intended.
on line 36 you made a table which has clones of the RedExplosion, and on like 68 you try to parent the table to workspace, does this work? Do you see those objects appear in the workspace explorer now that the damage is processing? If not then you may need to adjust how you’re getting that explosion effect in place. (I’ve not seen it done like this before, if it does work that’d be cool to know!)