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

Why does the GUI go to the top of the screen?

Asked by 8 years ago

I'm trying to make a main menu type GUI and I want the buttons to tween to the right a little when your mouse hovers over them and then to go back when the mouse leaves. For some reason when your mouse hovers over the button the GUI tweens to the top of the screen. Here is the code:

function me(button)
    button.MouseEnter:connect(function()
        button:TweenPosition(UDim2.new(0.5, 0,button.Position.Y), "Out", "Quad", 3, true)
    end)
    button.MouseLeave:connect(function()
        button:TweenPosition(UDim2.new(0.5, -50,button.Position.Y), "Out", "Quad", 3, true)
    end)        
end

me(script.Parent.Credits)
me(script.Parent.Play)

NOTE: I'm very new to Udmi2 and tweening. Thanks!

0
try setting offset(first numver in you udim2.new) to 0 koolkid8099 705 — 8y
0
its definetly the way you have youre numbers set up bubbaman73 143 — 8y
0
can you give me the position of the guis (labeled please) bubbaman73 143 — 8y
0
Credits: {0.5, -50},{0.5, 25} Play: {0.5, -50},{0.5, -50} Leg0brick 10 — 8y

1 answer

Log in to vote
1
Answered by 8 years ago

The TweenPosition() function called on lines 3 and 6 have a couple of issues: There is no offset on the Y-Scale listed. The proper format for a UDim2.new() function looks like this: UDim2.new(xScale,xOffset,yScale,yOffset). To fix the first issue in the script, change both lines 3 and 6 to this:

button:TweenPosition(UDim2.new(0.5,0,button.Position.Y,0),"Out","Quad",3,true)
--and
button:TweenPosition(UDim2.new(0.5,-50,button.Position.Y,0),"Out","Quad",3,true)

Now for the second issue: The button.Position.Y property is actually two properties. button.Position.Y contains two values, the scale and offset. The proper property for the button's Y-Scale is button.Position.Y.Scale. The final versions of lines 3 and 6 should look like this:

button:TweenPosition(UDim2.new(0.5,0,button.Position.Y.Scale,0),"Out","Quad",3,true)
--and
button:TweenPosition(UDim2.new(0.5,-50,button.Position.Y.Scale,0),"Out","Quad",3,true)

For more information, read up on UDim2.new() and TweenPosition() here and here. I hope this helped!

Ad

Answer this question