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

Telling a block to move down wont go down?

Asked by
B_Iu 31
7 years ago

Ok, I have made a script to make script.parent go up then in ten seconds go down. I dont know why, but what it does is it goes up, then goes up again without going down.... Help please

while true do
wait()
for i= 1, 50 do
script.Parent.CFrame = script.Parent.CFrame * CFrame.new(0,0.28,0)
wait()
end
wait(10)
for i= 1, 50 do
script.Parent.CFrame = script.Parent.CFrame * CFrame.new(0,-0.28,0)
wait()
end
end``
0
Having the Y value in line 6 as a negative value makes it go up, and same if it's a positive value? noob1126 34 — 7y
0
Line 9 not 6 sorry** noob1126 34 — 7y
0
Apparently it does. I have no idea what to do. B_Iu 31 — 7y

1 answer

Log in to vote
0
Answered by 7 years ago

The issue here is after it goes down, it waits a single frame before starting the loop again. Also, I would recommend putting an actual value on the wait to show the part transitioning. It would look like this:

while true do
    wait()
    for i= 1, 50 do
        script.Parent.CFrame = script.Parent.CFrame * CFrame.new(0,0.28,0)
        wait(0.05)
    end
    wait(10)
    for i= 1, 50 do
        script.Parent.CFrame = script.Parent.CFrame * CFrame.new(0,-0.28,0)
        wait(0.05)
    end
    wait(10)
end
0
Thanks! B_Iu 31 — 7y
0
wait() has nothing to do with frame rate. User#5423 17 — 7y
0
I thought wait() would wait a single frame due to not being given a parameter. Oh well, either way it's the same point iamnoamesa 674 — 7y
Ad

Answer this question