I made a local script that is placed directly into the Button and it adds a cool hover effect. I decided I want to have a local script under the ScreenGui that not only allows the Button to hover but any other button I add to the MainGui to have the same kind of effect without having to make another script.
I checked and couldn't find any reason the script is locating the Button as it should, but maybe that isn't the issue.
wait() local OpenButton = script.Parent.NavButton.Open:WaitForChild("Button") OpenButton.MouseEnter:connect(function() print("Mouse Entered") OpenButton:TweenPosition(UDim2.new(3.289, 0, 1.919, 0), "Out", "Quad", 0.2, true) end) OpenButton.MouseLeave:connect(function() print("Mouse Leave") OpenButton.TweenPosition(UDim2.new(3.289, 0, 2.019, 0), "Out", "Quad", 0.2, true) end)
If you guys find the problem please let me know and I'll try and fix it!
I think the error here is because you're calling mouse leave, but you cant run mouse leave if it hasnt entered:
So you would do something like:
Button.MouseEnter:Connect(function() -- Do something here Button.MouseLeave:Connect(function() -- Do something when it leaves. end) end)
So your code should look like:
wait() local OpenButton = script.Parent.NavButton.Open:WaitForChild("Button") OpenButton.MouseEnter:connect(function() print("Mouse Entered") OpenButton:TweenPosition(UDim2.new(3.289, 0, 1.919, 0), "Out", "Quad", 0.2, true) OpenButton.MouseLeave:connect(function() print("Mouse Leave") OpenButton.TweenPosition(UDim2.new(3.289, 0, 2.019, 0), "Out", "Quad", 0.2, true) end) end)
Hope this works!