I’ll come back with a solution once I figure out what’s going on!
Okay so I fixed it, I made the OnHover X scale to 0.019 and the OnExit X scale to -0.001 and set override to true
TweenFix.rbxl (29.2 KB)
The button doesn’t move backwards? If you’re not getting what I’m trying to do:
I’m trying to make it so that, when a button is hovered over, it moves forward. Then, when you stop hovering over it, it moves back to the original position.
Huh? it was working for me, did I accidentally forget to save, let me check it out
No, I tried setting the X onHover to 0.019, and the OnExit to -0.001, and override to true, and it didn’t work.
Did you make any other changes?
I don’t know why, but my device is unable to open .rbxl files in studio.
Did you set Override to true
for both of the TweenPositions? Could you download the new rbxl on my post and check out if what I did actually works and if it does you coudl just copy and paste the code to your studio place
I may be doing something wrong, could you tell me how you open .rbxl files?
And yes, I did set override to true on both.
Here’s my code:
local GuiLayer = script.Parent:GetChildren() -- Gets everything on the same layer as the script
local function onHover(item)
local currentpos = item.Position
print("run")
item:TweenPosition(
UDim2.new(currentpos.X.Scale + 0.019, 0, currentpos.Y.Scale + 0, 0),
"Out", -- easing direction
"Quad", -- easing style
0.1, --time in seconds
true --override?
)
end
local function onExit(item)
local currentpos = item.Position
print("run")
item:TweenPosition(
UDim2.new(currentpos.X.Scale + -0.001, 0, currentpos.Y.Scale + 0, 0),
"Out", -- easing direction
"Quad", -- easing style
0.1, --time in seconds
true --override?
)
end
for _, item in ipairs(GuiLayer) do
if item:IsA("TextButton") then -- Checks if the Item is a TextButton, for example
item.MouseEnter:Connect(function() -- Activates the function called "onHover" whenever any of those items are hovered over
onHover(item)
end)
item.MouseLeave:Connect(function()
onExit(item)
end)
end
end
I think what you could jsut do is Double click the rbxl to open it
Let me try again, it didn’t work last time for me.
That’s your issue haha! Remove the currentpos.X.Scale +
from both of the TweenPositions, I hardcoded the X scale, I should have specified that, my bad!
Thank you! Issue’s been solved, and all I need to do now is edit the tween.
Alright! I wish you good luck and if you have anymore issues don’t be afraid to make another post!!