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

How would I move a gui up and down the Y-AXIS of the screen?

Asked by 9 years ago
if script.Parent.Position == UDim2.new(0,0,0.1,0) then
repeat
wait(.1)
script.Parent.Position = UDim2.new(0,0,YS-.1,0) ...
[MORE CODE HERE]

I tried to code it that way, but it does not move the gui's position. Am I doing something wrong? Of course, I cut off some lines because you don't really need to see them. This is the part where they're supposed to move but don't move. Please help with my snippet.

1 answer

Log in to vote
0
Answered by 9 years ago

What you would like to do here is something called Tweening. It allows you to slide the gui along the screen towards a certain point or grow/shrink it to a certain point. You would use TweenPosition to move the position. If you want it to move up the y axis to the very top and then down to the very bottom repeatedly, you would use the follow code. The other problem that you are having is that you are trying to check the position of the gui with UDim2.new when instead you should use if script.Parent.Position.Y.Scale == .1 then. If you need any more help or explaining just leave a comment.

while true do
script.Parent:TweenPosition(UDim2.new(0, 0, 0, 0), "Out", "Linear", 1) --the 1 at the end is how long it should take(1 second right now)
wait(1)
script.Parent:TweenPosition(UDim2.new(0, 0, 1, -script.Parent.Size.AbsoluteSize.Y), "Out", "Linear", 1) -- the 1 is the time again, the reason I put in script.Parent.Size.AbsoluteSize.Y is so that it just touches the bottom edge but does not go past it
wait(1)
end
Ad

Answer this question