BlueDannyJoin Date: 2010-11-11 Post Count: 227 |
I'm trying to make this object bob in the air 5 blocks high then back down 5 blocks until another script interupts it..
But it's not working out very well :l
It just flies straight up in the air.. Help??
Script::
Part = game.Workspace.Atom
repeat
local i = 5, -5, 0.1
Part.CFrame = Part.CFrame + Vector3.new(0,i,0)
wait()
until Part.CFrame.Y <= 18.5 |
|
BlueDannyJoin Date: 2010-11-11 Post Count: 227 |
I meant for the last line to be:
until Part.CFrame.Y <= 18.5
|
|
blockooJoin Date: 2007-11-08 Post Count: 17202 |
I think what you want is a "for" loop:
Part = game.Workspace.Atom
for i = -5, 5, 0.1 do
Part.CFrame = Part.CFrame + Vector3.new(0, i, 0)
wait()
end
That will only make it go up though, and not down. |
|
BlueDannyJoin Date: 2010-11-11 Post Count: 227 |
Well, perhaps I did this :
Part = game.Workspace.Atom
for i = 0.1, 100 do
i = 0.1
Part.CFrame = Part.CFrame + Vector3.new(0, i, 0)
wait()
end
Which makes it rise 0.1 of a brick 100 times,
Well, how could I have the this:
Part = game.Workspace.Atom
for i = -0.1, 100 do
i = -0.1
Part.CFrame = Part.CFrame + Vector3.new(0, i, 0)
wait()
end
Lower it to it's original position
HOW CAN I MIX THEM TOGETHER TO DO IT FOREVER? |
|
blockooJoin Date: 2007-11-08 Post Count: 17202 |
Your loops and variables are kind of iffy. Use this:
function float()
for i = 1, 100 do
Part.CFrame = Part.CFrame + Vector3.new(0, 0.1, 0)
wait()
end
for i = 1, 100 do
Part.CFrame = Part.CFrame - Vector3.new(0, 0.1, 0)
wait()
end
float()
end
float() |
|
doneyesJoin Date: 2008-03-21 Post Count: 3466 |
loop |
|
BlueDannyJoin Date: 2010-11-11 Post Count: 227 |
This works as well..
Part = game.Workspace.Atom
while true do
for i = 0.1, 100 do
i = 0.1
Part.CFrame = Part.CFrame + Vector3.new(0, i, 0)
wait()
end
for i = -0.1, 100 do
i = -0.1
Part.CFrame = Part.CFrame + Vector3.new(0, i, 0)
wait()
end
end |
|
blockooJoin Date: 2007-11-08 Post Count: 17202 |
@BlueDanny
It may work, but you can clean it up quite a bit. You don't need the "i = 0.1" and "i = -0.1" lines. Also, your for loops are only counting in increments of 1, so stating on 0.1 isn't really necessary. "for i = 1, 100 do" looks better and works the same. |
|
zub74Join Date: 2008-09-13 Post Count: 489 |
As for your until another script interrupts it part, just put something like this right after the beginning of your loop:
if Workspace.Interrupter.Value=false then
and after the rest of your script:
else script.Parent:Destroy()
end
Just make a bool value named Interrupter in workspace or wherever. |
|
zub74Join Date: 2008-09-13 Post Count: 489 |
Sorry, don't know why I threw in .Parent... Just script:Destroy() |
|