Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
1

Why isn't my second For i,v loop getting fired after the first one?

Asked by
rexpex 45
7 years ago

So i made a script that makes a BodyVelocity in someone's UpperTorso, then the for i,v speed of the Velocity decreases it. Afterwards, the second for i,v loop starts and makes a part that has the position of the player with the BodyVelocity, but for some reason it doesn't get fired.

baseAtk = 25
replicatedstorage = game:GetService("ReplicatedStorage")
RicoClass = replicatedstorage.RicoClass
Ult = RicoClass:FindFirstChild("Ultimate")
debounce = true
tool = script.Parent.Parent.Parent


Ult.OnServerEvent:connect(function(player)
local players = game.Workspace:GetChildren()
local root = player.Character.HumanoidRootPart
local bv = Instance.new("BodyVelocity")

for i,v in pairs(players)do
local here = v:findFirstChild("Humanoid")
    if v:findFirstChild("Humanoid")and here ~= player.Character:FindFirstChild("Humanoid") then
        if (root.Position - v.UpperTorso.Position).magnitude <=35 then

        bv.Parent = v.HumanoidRootPart
        bv.MaxForce = Vector3.new(1e8,1e8,1e8)
        bv.Velocity = v.HumanoidRootPart.CFrame.upVector * 23
        wait()
            for i = 23,-1,-1 do
                wait(0.01)
                bv.Velocity = v.HumanoidRootPart.CFrame.upVector + Vector3.new(0,i,0)
            end
local l = RicoClass.WaveP:clone()
l.Parent = game:GetService("Workspace").Attacks["Rico's Attacks"]
l.Transparency = 0
l.CFrame = CFrame.new(v.UpperTorso.Position)

for b = 1,0 do
    wait(0.1)
        l.Transparency = b
        l.Size = l.Size + Vector3.new(b,b,b)

    end
    end
    end
end 
end)

1 answer

Log in to vote
1
Answered by 7 years ago

Hi!

Your second For i,v loop won't do anything because b is valueless. You need to add another comma and put "-1", so the loop knows to go down by 1. It is instead trying to go up by 1, which it can't.

for b = 1,0,-1 do
    wait(0.1)
    l.Transparency = b
    l.Size = l.Size+Vector3.new(b,b,b)
end
0
OH I HADN'T REALIZED rexpex 45 — 7y
Ad

Answer this question