Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

Moving gui across screen? SOLVED!

The script below makes a gui go from left to right. So I make this gui start from the right side of the screen and it goes to the left. Whenever it goes to the left, the gui just disappears. I want whenever it disappears from the left side of the screen, I want it to appear back on the right side of the screen and repeat.

while true do
	script.Parent.Position=script.Parent.Position-UDim2.new(0.005,0,0,0)-- "-" makes it go from right to left
	wait()
end

2 answers

✓ Accepted answer

Updated

Try this:

Startposition=script.Parent.Position

while true do
	local RightBorder=script.Parent.AbsolutePosition.X+script.Parent.AbsoluteSize.X
	if RightBorder<=0 then
		script.Parent.Position=Startposition
	else
		script.Parent.Position=script.Parent.Position-UDim2.new(0.005,0,0,0)
	end
	wait()
end

Anyways, this should work correctly now. If not, or if you have any further questions, please leave a comment below. Hope I helped :P

3 comments

0

Thank you, it works when it hits the side of the screen but it changes the position. How do I make it as the same position as it is before?

0

Oh, i'll adjust it to do that, hold on a min :P

0

Fixed it. I think that's what you meant.

You didnt use TweenPosition!

(note pick a position to start at(no script) then pick where you want it to move)

while true do
		script.Parent:TweenPosition(UDim2.new(number, number, number, number), "Out", "Quad", number, true or false) -- quad and out are just the default or something like that
	wait(number)
script.Parent:TweenPosition(UDim2.new(original pos., original pos., original pos., original pos.), "Out", "Quad", number, true or false) 
end

For more info visit this http://wiki.roblox.com/index.php?title=TweenPosition

6 comments

0

There is an error w/ this script. What is wrong?

0

lemme try it real quick

0

i forgot to add )'s at the end of the true or false things! just add those and you should be fine

0

there we go i edited it and i should work

0

All I have to do is copy the script and paste it right? Dont change anything??

0

no, you have to change the numbers, and decide if you want true or false

This discussion is preserved as it was. New answers, comments, and votes are closed.