What do you want to achieve? I have an animation that kinda resembles a stand barrage from Jojo’s bizarre adventure. I am trying to have it do fluent damage
What is the issue? It just instantly kills the target. I use this same script for all of my other attacks but tried to implement a loop.
What solutions have you tried so far? I’ve tried looping and manuel, none worked.
LocalHumPart = script.Parent:FindFirstChild("HumanoidRootPart")
Character = script.Parent
Anim = Instance.new("Animation")
Anim.AnimationId = "rbxassetid://5471634980"
function Barrage(player)
if game.Players:GetPlayerFromCharacter(script.Parent) == player then
if LocalHumPart.Stand.Value == true then
if script.Parent:FindFirstChild("Pose").Pose.Value == false then
if LocalHumPart.CanAttackRN.Value == true then
local Stand = script.Parent:WaitForChild("Stand")
local Barrage = 0
local playAnim = Stand.AnimationController:LoadAnimation(Anim)
playAnim:Play()
repeat
local touch = false
Stand:FindFirstChild("Left Arm").Touched:Connect(function(part)
Hum = part.Parent:FindFirstChild("Humanoid")
if Hum then
touch = true
else
touch = false
end
end)
if touch == true then
touch = false
Hum.Health = -2
end
Barrage = Barrage + 1
wait(0.2)
Stand:FindFirstChild("Right Arm").Touched:Connect(function(part)
Hum = part.Parent:FindFirstChild("Humanoid")
if Hum then
touch = true
else
touch = false
end
Barrage = Barrage + 1
end)
if touch == true then
touch = false
Hum.Health = -3
end
until Barrage == 30
end
end
end
end
end
game.ReplicatedStorage.Folder.TheWorld1.AttackE.OnServerEvent:Connect(Barrage)
I know I’m very late but instead of touched use a repeat until looped with magnitude damage.
Example:
local BarrageDb = false
local isBarraging = false
local function BarrageButtonDown()
if BarrageDb then return end
isBarraging = true
local Barrage = "Animation Track Here"
Barrage:Play()
delay(4.65,function() --// This is how long you can hold the barrage key down before you can't continue
if isBarraging then
isBarraging = false
end
end)
repeat wait(0.075) --// or how long per hit
for i,v in pairs(workspace:GetChildren()) do
if v:IsA("Model") and v:FindFirstChild("HumanoidRootPart") and v:FindFirstChildOfClass("Humanoid") then
if (("InsertWhereYourStandIsLocated").HumanoidRootPart.Position - v:FindFirstChild("HumanoidRootPart").Position).Magnitude <= 10.5 then --// 10.5 is kinda large ik but you can make the number smaller so you need to be closer to do damage.
if plr.Character ~= v then
--// Do Damage, v is the model that you are trying to do damage to
end
end
end
end
until not isBarraging
Barrage:Stop()
BarrageDb = true
isBarraging = false
local Cooldown = 5.5
delay(Cooldown,function()
BarrageDb = false
end)
end
local function BarrageButtonUp()
if BarrageDb then return end
if isBarraging then
isBarraging = false
end
end
I used a similar version of this for my jojo game and it works fantastic.
Once again really sorry that I’m so late.
.Touched is very unreliable you should probably use magnitude or region3.
From the first script provided, it just seems that your setting the targets health to -3
if you used :TakeDamage() or Hum.Health = Hum.Health - 2 I think it’d work