local Mouse = game.Players.LocalPlayer:GetMouse()
local Frame = script.Parent
local Btn = Frame.Resize
local Offset = nil
local MinimumX, MinimumY = 0, 0
local MaxX, MaxY = math.huge, math.huge
local Resizing = false
local UIS = game:GetService('UserInputService')
Btn.MouseButton1Down:Connect(function()
Offset = Vector2.new(Mouse.X-(Frame.AbsolutePosition.X+Frame.AbsoluteSize.X),Mouse.Y-(Frame.AbsolutePosition.Y+Frame.AbsoluteSize.Y))
Resizing = true
local a = true
UIS.TouchEnded:Connect(function()
if a then
a = false
Resizing = false
end
end)
end)
Btn.MouseButton1Up:Connect(function()
Resizing = false
end)
Mouse.Move:Connect(function()
if Resizing then
if not UIS:IsMouseButtonPressed(Enum.UserInputType.MouseButton1) then
Resizing = false
end
local oldPosX, oldPosY = Frame.Size.X.Offset, Frame.Size.Y.Offset
local mousePos = Vector2.new(Mouse.X - Offset.X,Mouse.Y - Offset.Y)
local finalSize = Vector2.new(math.clamp(mousePos.X - Frame.AbsolutePosition.X, MinimumX, MaxX), math.clamp(mousePos.Y - Frame.AbsolutePosition.Y ,MinimumY, MaxY))
Frame.Size = UDim2.fromOffset(finalSize.X,finalSize.Y)
end
end)
Basically, when I try to go in game and resize it on mobile, it doesn’t detect the mouse position really well, so it makes it hard to resize the GUI to whatever size you like
As for mobile, it won’t detect due to be no mouse connected so it’ll wouldn’t really function as well, you could check if there’s a mouse available and if not you can use UserInputService, some of the functions are similar to MouseButton1Up & MouseButton1Down
Obtaining input on PC and Mouse use two entirely different methods; and to detect the input method of user, I suggest you check for UserInputService.KeyboardEnabled or UserInputService.TouchEnabled and based on it, run either the PC Input System or Mobile Input system.
You need to capture Touch events and not just mouse events, or at least separate the Begin and End and not tie them to the same logic as mouse input. i.e. use UIS:InputBegan() UIS:InputEnded() and check the provided parameters to ascertain the type.
local function InputBegan(input, _gameProcessed)
if input.UserInputType == Enum.UserInputType.MouseButton1 then
print("The left mouse button has been pressed!");
end
end