I’ve recently been trying to make something like a fireball, and today I was successful in doing it. However, my code isn’t looped and its just changing the position once, waiting for a tenth of a second, going again… and so on. Here is my code:
local fireball = script.Parent
fireball.Transparency = 0.5
wait(10)
print("First move")
fireball.Position = Vector3.new(-67, 2, 65)
wait(0.1)
print("Second move")
fireball.Position = Vector3.new(-67, 2, 60)
wait(0.1)
print("Third Move")
fireball.Position = Vector3.new(-67, 2, 40)
I know that if I want to make this work correctly that I would need a loop, so here is what I think I should do for the loop:
local fireball = script.Parent
local increment = 3
local currentPos = [currentPos.X, currentPos.Y, currentPos.Z)
for wait(5), wait(10), 3 do
fireball.Position = Vector3.new(currentPos[0], currentPos[1], currentPos[2] + increment)
--Did I reference the array positions correctly?
end
However, I don’t know if I put the code correctly in the way I wanted. To explain what’s happening in the for loop, you wait 5 seconds for the fireball to start moving, then you run that for 10 seconds then stop, then the value is 3 because that’s what I want the increment to be. Is this correct??