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

What is wrong with this script?

Asked by 10 years ago

I have a script that is supposed to make a spawn go up and down continuously... But it doesn't work. (This script is a regular script inside of a spawn)

spawn = script.Parent


function UpAndDown()
    for i = 0, 4, 0.1 do
        spawn.CFrame = CFrame.new(0, 0.1, 0)
        wait(0.1)
    end

    for i = 0, -4, -0.1 do
        spawn.CFrame = CFrame.new(0, -0.1, 0)
        wait(0.1)
    end

    UpAndDown()
end


UpAndDown()

0
I probably did this completely wrong but i'm new to scripting and this is what i thought i was supposed to do... starkiller523 65 — 10y

1 answer

Log in to vote
1
Answered by
JuHDude 25
10 years ago

I changed a few things, but it's pretty simple. It should work now. If you want it to be continuous all you have to do is introduce a loop (while true do).

spawn = script.Parent

function UpAndDown()
    for i = 0, 4, 0.1 do
        spawn.CFrame = spawn.CFrame + Vector3.new(0, 0.1, 0)
        wait(0.1)
    end
    for i = 0, 4, 0.1 do
        spawn.CFrame = spawn.CFrame - Vector3.new(0, 0.1, 0)
        wait(0.1)
    end
end

while true do
    UpAndDown()
    wait(1)
end

0
Thanks. starkiller523 65 — 10y
Ad

Answer this question