✓ Accepted answer
Here's the solution to your problem:
local x = 100.497
local z = -56.4
while wait() do
for yup = 23.892,26.892,.1 do
script.Parent.Position = Vector3.new(x,yup,z)
end
for ydown = 26.892,23.892,-.1 do
script.Parent.Position = Vector3.new(x,ydown,z)
end
end
All you really had to do is inverse the for loops. What the "yup" for loop does is change yup from 23.892 to 26.892 in increments of positive 0.1. "ydown" changes from 26.892 to 23.892 in increments of -0.1.
Here's a somewhat improved version of your script:
local basePosition = Vector3.new(100.497, 23.892, -56.4)
while wait() do
for yup = basePosition.Y, basePosition.Y + 3, 0.1 do
script.Parent.Position = Vector3.new(x, yup, z)
end
for ydown = basePosition.Y + 3, basePosition.Y, -0.1 do
script.Parent.Position = Vector3.new(x, ydown, z)
end
end
This solution just uses one Vector3 to represent a base position and manipulates it in a for loop to get the target position on the y-axis.
I would also recommend that you use a wait() somewhere in those for loops, otherwise it would be just like setting their position to the end-result of the for loop instantly.
Good luck! I hope this helps.
2 comments
Please properly format your code so that people will be better able to help you.
Sorrrryy, I forgot to format it and didn't check back. //qq