I tried to make the barrier destroy after it did the damage but it didnt work
its in line 37 - 42
Here is the script:
local Tool = script.Parent
Tool.RemoteEvent.OnServerEvent:Connect(function(Player, Debounce)
local Character = Player.Character
local hum = Character.Humanoid
Debounce = true
local Barrier = Instance.new("Part")
Barrier.BrickColor = BrickColor.new("Lime green")
Barrier.Material = "Neon"
Barrier.Transparency = 0.25
Barrier.Anchored = false
Barrier.Size = Vector3.new(8,13,1)
Barrier.Shape = Enum.PartType.Block
Barrier.Locked = true
Barrier.CanCollide = false
Barrier.CFrame = Character.HumanoidRootPart.CFrame
Barrier.Parent = Character
local bv = Instance.new("BodyVelocity")
bv.MaxForce = Vector3.new(math.huge,math.huge,math.huge)
bv.Velocity = Character.HumanoidRootPart.CFrame.lookVector * 25
bv.Parent = Barrier
Barrier.Touched:Connect(function(hit)
local ehum = hit.Parent:findFirstChild("Humanoid") or hit.Parent.Parent:findFirstChild("Humanoid")
if ehum and ehum ~= hum then
ehum:TakeDamage(10)
if ehum:TakeDamage(10)then
wait()
Barrier:Destroy()
end
end
end)

3 comments
debounce the touched event
how?
why is huge whitespace