I made a tool in my game that is supposed to deal damage to another player from an explosion but when it hits a player, no damage is dealt, but when i do it on a Rig it works deals damage.
Heres the code
local Tool = script.Parent
local debounce = false
local punch2id = "http://www.roblox.com/asset/?id=17629376734"
local ToolChildren =Tool.Handle:GetChildren()
Tool.Equipped:Connect(function(mouse)
local toolchildren = Tool.Handle:GetChildren()
local character = Tool.Parent
local humanoid = character.Humanoid
Tool.Activated:Connect(function()
if debounce == false then
local animation = Instance.new("Animation")
animation.AnimationId = "http://www.roblox.com/asset/?id=17619150351"
local animationtrack = humanoid:LoadAnimation(animation)
animationtrack:Play()
for count = 1, #ToolChildren do
local toolchild = ToolChildren[count]
toolchild.Transparency = 0
Tool.Handle.Transparency = 0
end
character.Humanoid.WalkSpeed = 0
character.Humanoid.JumpPower = 0
debounce = true
local hitbox = Instance.new("MeshPart")
hitbox.Parent = Tool.Handle.Cube
hitbox.Size = Vector3.new(10,10,10)
local weld = Instance.new("WeldConstraint")
hitbox.Position = Tool.Handle.Cube.Position
hitbox.CanCollide = false
hitbox.Massless = true
hitbox.Transparency = 1
weld.Parent = hitbox.Parent
weld.Part0 = hitbox.Parent
weld.Part1 = hitbox
local damageDebounce = false
animationtrack.Stopped:Wait()
for count = 1, #ToolChildren do
local toolchild = ToolChildren[count]
toolchild.Transparency = 1
Tool.Handle.Transparency = 1
end
character.Humanoid.WalkSpeed = 16
character.Humanoid.JumpPower = 50
local explosion = Instance.new("Explosion")
explosion.Parent = workspace
explosion.Position = Vector3.new(hitbox.Position.X,0,hitbox.Position.Z)
explosion.BlastRadius = 10
explosion.BlastPressure = 10
explosion.DestroyJointRadiusPercent = 0
local explosiondebounce = false
explosion.Hit:Connect(function(otherpart,distance)
if otherpart.Parent:WaitForChild("Humanoid") and explosiondebounce == false and otherpart.Parent.BlockValue.Value == false then
print("hit")
explosiondebounce = true
otherpart.Parent:WaitForChild("Humanoid"):TakeDamage(25)
elseif otherpart.Parent:WaitForChild("Humanoid") and explosiondebounce == false and otherpart.Parent.BlockValue.Value == true then
print("blocked")
explosiondebounce = true
otherpart.Parent:WaitForChild("Humanoid"):TakeDamage(15)
end
end)
local firePlace = Instance.new("Part")
local fire = Instance.new("Fire")
firePlace.Parent = workspace
firePlace.Position = hitbox.Position
fire.Size = 25
firePlace.Size = Vector3.new(10,10,10)
fire.Parent = firePlace
firePlace.CanCollide = false
firePlace.Anchored = true
firePlace.Position = Vector3.new(firePlace.Position.X,0,firePlace.Position.Z)
firePlace.Transparency = 1
local firedebounce = false
firePlace.Touched:Connect(function(otherpart)
if otherpart.Parent:FindFirstChild("Humanoid") and firedebounce == false then
local fireaura = Instance.new("Fire")
fireaura.Parent = otherpart.Parent.HumanoidRootPart
for count = 10, 0, -1 do
firedebounce = true
wait(0.5)
otherpart.Parent.Humanoid.Health = otherpart.Parent.Humanoid.Health - 1
end
firedebounce = false
fireaura:Destroy()
end
end)
hitbox:Destroy()
for count = 20,0,-1 do
Tool.Name = count
wait(1)
end
firePlace:Destroy()
Tool.Name = "Overcooked"
debounce = false
end
end)
end)
`