How make Gui with this position

So is there any way to give the gui this position?:

I am trying to create this gui for the interface of my RP game

1 Like

https://developer.roblox.com/en-us/api-reference/property/Mouse/X
https://developer.roblox.com/en-us/api-reference/property/Mouse/Y
https://developer.roblox.com/en-us/api-reference/function/UserInputService/GetMouseLocation
https://developer.roblox.com/en-us/api-reference/event/UserInputService/InputEnded

Yes, you can. Though you might script it for yourself using the links above this reply.

You can achieve this with UserInputService:GetMouseLocation() which returns the Vector2 position of the mouse. Here’s an example on how you would use it:

local RNS = game:GetService("RunService")
local UIS = game:GetService("UserInputService")

local frame = script.Parent

RNS.RenderStepped:Connect(function()
	local mouseLoc = UIS:GetMouseLocation()
	
	frame.Position = UDim2.new(0, mouseLoc.X + frame.AbsoluteSize.X / 1.3, 0, mouseLoc.Y + frame.AbsoluteSize.Y / 2)
end)

I managed to do what I hoped the only thing is that when a player clicks on the right side, the gui comes off the screen as seen in the video

Well you need a script that detects if the gui’s position is out of the screen.

Input events pass an ‘InputObject’ value to any callback functions connected to them, these values already contain positional information about the input.
https://developer.roblox.com/en-us/api-reference/property/InputObject/Position

local function OnInputEnded(InputObject, GameProcessed)
	if GameProcessed then return end
	print(InputObject.Position.X, InputObject.Position.Y) --Cursor's X and Y axis screen position (for mouse inputs).
end

Is there a way or a tutorial to do this? (I am not an expert)