Help with gui button moving

So, I’m trying to make a intro GUI, and when you hover over a button it will move like 5 studs to the right.

2 Likes

We can’t help you if you won’t provide any code. What have you tried to do so far?

2 Likes

Like what @lluckvy said, a code sample would really be helpful.

That’s the thing. I don’t know what the code would be to detect when its being hovered over.

Take a look at these links. Let me know if you need more info.

Use ui_object.MouseEnter:Connect(function() for detecing if it’s being hovered at, and use TweenService for moving it. If you have no idea how to create one, learn here. As @Discgolftaco231 linked, it’s also worth the time of checking MouseEnter and MouseLeave to understand them better.

1 Like

Use this code block:

GuiObject.MouseEnter:Connect(function()
    --Code to make button move	
end)

would I put the script / localscript into the frame or text button

You would put it in a LocalScript in a TextButton

what do I define GuiObject as because it looks like this
image

Well, if the script is inside of the button, replace it with

script.Parent

No, only UDim2. UIs are not parts and are ui objects.

Can you use Vector3 with GUIs?

Accidentally edited the top comment, read that one instead. A better visual for the code would be:

local ts = game:GetService("TweenService")
local button = script.Parent
local move = ts:Create(button, TweenInfo.new(1, Enum.EasingStyle.Quart, Enum.EasingDirection.InOut, 0, false, 0), {Position = UDim2.new(YOUR_POSITION_HERE)})
button.MouseEnter:Connect(function()
    move:Play()
end)

You can only use UI objects with UDim2, not Vector3 - as Vector3 is for parts in workspace, whilst a UI object is different from that.

What would the “YOUR_POSITION_HERE” be changed to if I was trying to make it move somewhere

Of course, the position of the TextButton.

The new or old position?

30 charssss

New position, as you want to create a new one and make it move.

Do I put this in?

image

Yes, that’s the position that it’ll move to.