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)
This could also be because it is hitting multiple parts of the game character, as a typical R15 character has 16 parts, it essentially does 160 damage, you can prevent this with a table of things it already hit, like StickMasterLuke did in his Mad Bloxxer tutorials.
local lastclick = tick() local Tool = script.Parent local hitHumanoids = {} Tool.RemoteEvent.OnServerEvent:Connect(function(Player) local Character = Player.Character local hum = Character.Humanoid 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) if hit and hit.Parent and game.Players:GetPlayerFromCharacter(hit.Parent) and not hit:isDescendantOf(Character) then local targethum = hit.Parent:FindFirstChild("Humanoid") if not hitHumanoids[targethum] then targethum:TakeDamage(10) hitHumanoids[targethum] = true --can be anything besides false or nil end end end) end) Tool.Activated:Connect(function() hitHumanoids = {} --resets hitHumanoids when the tool is clicked end)
This essentially makes a table of the humanoids hit/damaged, and checks if a humanoid that has been hit had been hit before, then if it didnt, it gets damaged and added to the table that is hitHumanoids
Simply use a cooldown or so called debounce into it. Here's an example:
--Script inside a part for example local cooldown = false script.Parent.Touched:connect(function(hit) if not cooldown and hit.Parent:FindFirstChild("Humanoid") then --If "cooldown" is "false" and it's a player then.. hit.Parent.Humanoid:TakeDamage(10) cooldown = true wait(5) --Wait 5 seconds before it deals damage again cooldown = false --Since "cooldown" is "false" again, the barrier will now deal damage again! end end)