So I am trying to make a tooltip gui on a tool whenever you hover over it. This will show the stuff the tool has. Basically I want it to auto size the gui to fit the text on the frame. I also want it to rotate the frame size from when the tool is hovered from the button to the top of the screen.
I am really new to this stuff so I don’t know where to start. I am in need of some steering in the right direction.
Thanks!
Basically if the weapon is hovered from the bottom half of the screen, the frame with the tooltips will rotate itself so the “end” or longer part of the frame is going towards the center of the screen. Same thing with the top, the longer/end part of the frame will go towards the center of the screen.
You would have to create some conditionals in your MouseMoved function by fetching the mouse position and determining if it’s above or below half of the screen. Then you can apply rotation.
To fetch the current mouse position, you can either use LocalPlayer:GetMouse().X / LocalPlayer:GetMouse().Y or use the returning parameters from the MouseMoved event which also return X and Y.
To check if the mouse is on top or on bottom, you will have to determine the screen size Y. You can easily get the screen size by reading it from a ScreenGui’s Absolute Size property.
Then once you have determined if it’s on the top or bottom, you can rotate the frame however you like.
This is an example of how that function would look:
ToolFrame.MouseMoved:connect(function(MouseX,MouseY)
local Side = (ScreenGui.AbsoluteSize.Y/2) - MouseY --If mouse is above the top half of screen -> value will be positive, if it is below half -> value will be negative
local RotationIncrement = 60 --How much you want the tooltip to be rotated
local AdjustmentX, AdjustmentY = 1,1 --These adjustments will need tweaking depending on the rotation increment and tooltip frame size†
if Side >= 0 then --If mouse is topside (positive)
ToolTip.Rotation = RotationIncrement
ToolTip.Position = UDim2.new(0,MouseX - AdjustmentX,0,MouseY - AdjustmentY)
elseif Side < 0 then --If mouse is bottomside (negative)
ToolTip.Rotation = ( -1 * RotationIncrement ) --Applies the inverse since we want it to face up towards the center of the screen instead of downwards
ToolTip.Position = UDim2.new(0,MouseX + AdjustmentX,0,MouseY + AdjustmentY)
end
end)
† This is due to AnchorPoints not respecting rotation data. Unfortunately, I’m not aware of a workaround and Roblox has still not given Gui objects proper rotation support so you would have to figure the adjustments out through trial and error.