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

How do I make it so that the second part will do the same thing as the first part in this for loop?

Asked by 5 years ago
Edited 5 years ago
        local offset = CFrame.new(0,0,10)
        local point = CFrame.new(plr.Character.HumanoidRootPart.CFrame.lookVector)  

        local  F1 = game.ReplicatedStorage.F1:Clone()
        local F2= game.ReplicatedStorage.F2:Clone()
        F2.Parent = game.Workspace
        F1.Parent = game.Workspace



        while  true do

            local point = CFrame.new(plr.Character.HumanoidRootPart.Position)


            for i = 1,360 do

                F1.CFrame = point * CFrame.Angles(0,math.rad(i),0) * offset         

                wait()                          
            end


For this specific part in my script Im having troubles. Now F1 is the first ball that circles the player. It works just fine, it goes around the player just how I want it. But I dont know how to do that for F2. I want a wait of 1 second before it starts to rotate as well so it isnt inside the first ball. When I add a wait inside the for loop it messes up the rotation and still has the second ball inside the first, could someone explain how I would make the second ball (F2) go around the player as well but wait 1 second?

1 answer

Log in to vote
0
Answered by 5 years ago
local offset = CFrame.new(0,0,10)
local point = CFrame.new(plr.Character.HumanoidRootPart.CFrame.lookVector)  

local  F1 = game.ReplicatedStorage.F1:Clone()
local F2= game.ReplicatedStorage.F2:Clone()
F2.Parent = game.Workspace
F1.Parent = game.Workspace



while  true do
    local point = CFrame.new(plr.Character.HumanoidRootPart.Position)

    spawn(function()
        for i = 1,360 do
            F1.CFrame = point * CFrame.Angles(0,math.rad(i),0) * offset         
            wait()                          
        end
    end)

    wait(1)

    for i = 1,360 do
        F2.CFrame = point * CFrame.Angles(0,math.rad(i),0) * offset         
        wait()                          
    end
end
0
Please explain your answer. User#19524 175 — 5y
Ad

Answer this question