I made a damage splash and I want to make it spawn a hitbox at its position when it hits a surface.
clonedPot.Handle.Touched:Connect(function(hit)
if hit then
local clonedHitbox = hitbox:Clone()
clonedHitbox.CanTouch = true
clonedHitbox.Position = clonedPot.Handle.Position
clonedHitbox.Parent = model
clonedHitbox.Touched:Connect(function(otherPart)
local character = otherPart.Parent
local humanoid = character:WaitForChild("Humanoid")
humanoid.Health -= 250
print(character.Name)
clonedHitbox.CanTouch = false
end)
end
end)
The code above doesn’t seem to work at all. As in the fact that the hitbox doesn’t show up.
function Weld(Part0, Part1, C0, C1)
local Weld = Instance.new("Weld")
Weld.Part0 = Part0
Weld.Part1 = Part1
Weld.C0 = C0 or CFrame.new()
Weld.C1 = C1 or Part1.CFrame:ToObjectSpace(Part0.CFrame)
Weld.Parent = Part0
return Weld
end
clonedPot.Handle.Touched:Connect(function(hit)
if hit then
local clonedHitbox = hitbox:Clone()
clonedHitbox.CanTouch = true
clonedHitbox.Position = clonedPot.Handle.Position
clonedHitbox.Parent = model
Weld(clonedHitbox, clonedPot.Handle)
clonedHitbox.Touched:Connect(function(otherPart)
local character = otherPart.Parent
local humanoid = character:WaitForChild("Humanoid")
humanoid.Health -= 250
print(character.Name)
clonedHitbox.CanTouch = false
end)
end
end)