I'm trying to make some consecutive fireball attack but for some reason instead of dealing 5 damage each fireball it deals 25 - 35 damage all at once and doesn't do damage after 1 hit there are 6 fireballs btw
Server Script:
dmgRemote.OnServerEvent:Connect(function(plr, hb, char)
local hbhit = workspace:FindPartsInRegion3(hb, nil, 1000 )
for i, v in pairs(hbhit) do
if v.Parent == char then return end
if v.Parent:FindFirstChild("Humanoid") then
if isHit then return end
spawn(function()
isHit = true
wait(.3)
isHit = false
end)
local eHum = v.Parent:FindFirstChild("Humanoid")
print("damage")
eHum:TakeDamage(5)
end
end
end)
local script:
spawn(function()
for i = 0, 5, 1 do
wait(.1)
local fb = rs.MagicModels.Damage.Fire.ConsecutiveFireballs:WaitForChild("Fireball", 1):Clone()
fb.Name = plr.Name.." fb"
fb.Parent = folder
fb.CFrame = hrp.CFrame * CFrame.new(0,2,-2)
fb.Orientation = fb.Orientation + Vector3.new(-10,10,10)
game.Debris:AddItem(fb, 5)
local bv1 = Instance.new("BodyVelocity")
bv1.Name = "FireballBv"
bv1.Velocity = Mouse.Hit.lookVector * 100
bv1.MaxForce = Vector3.new(1e8,1e8,1e8)
bv1.Parent = fb
fb.Touched:Connect(function(hit)
if hit.Parent == char then return end
if hit and hit:IsA("BasePart") and hit.CanCollide == true then
fb:Destroy()
local e1 = rs.MagicModels.Damage.Fire.ConsecutiveFireballs.Explosion1:Clone()
local e2 = rs.MagicModels.Damage.Fire.ConsecutiveFireballs.Explosion2:Clone()
e1.Name = plr.Name.." Explosion1"
e2.Name = plr.Name.." Explosion2"
e1.Parent = workspace
e2.Parent = workspace
local e1ti = TweenInfo.new(1, Enum.EasingStyle.Quad, Enum.EasingDirection.Out, 0, false, 0)
local e2ti = TweenInfo.new(1, Enum.EasingStyle.Quad, Enum.EasingDirection.Out, 0, false, 0)
local e1pp = {Transparency = 1, Size = Vector3.new(9.818, 9.941, 9.63)}
local e2pp = {Transparency = 1, Size = Vector3.new(9.703, 9.928, 9.504)}
local e1t = ts:Create(e1, e1ti, e1pp)
local e2t = ts:Create(e2, e2ti, e2pp)
e1t:Play()
e2t:Play()
e1.CFrame = fb.CFrame
e2.CFrame = e1.CFrame
e1t.Completed:Connect(function()
e1:Destroy()
e2:Destroy()
end)
local Size = Vector3.new(9.703, 9.928, 9.504)
local pos = e1.Position
local hb = Region3.new(pos - e1.Size/2, pos + e1.Size/2)
dmgremote:FireServer(hb, char)
spawn(function()
for i = 1, 3 do
wait()
char.Humanoid.CameraOffset = Vector3.new(math.random(-100, 100)/ 100,math.random(-100, 100)/ 100 ,math.random(-100, 100)/ 100)
wait()
char.Humanoid.CameraOffset = Vector3.new(0,0,0)
end
end)
end
end)
