Universal Script 📌
2.2k Views
36 Executions

Mobile Support Drag UI

Universal Script 📌
lumpiasallad
lumpiasalladFirst script
2 years ago
Get an executor
Please login to perform these actions:

Does it work?

No reports yet

No reports yet. Tried it? Be the first to say.

Also noticed:

Description

This is for developers only Those who need a script that helps Mobile support

View Raw
--[[
Made By: lumpia
]]

local UserInputService = game:GetService("UserInputService")
local Players = game:GetService("Players")
local localPlayer = Players.LocalPlayer
local mouse = localPlayer:GetMouse()

-- Helper: Clamp a UDim2 position within screen bounds
local function clampToScreen(frame, newPos)
    local parent = frame.Parent
    local screensize
    if parent:IsA("ScreenGui") then
        screensize = parent.AbsoluteSize
    elseif parent.Parent and parent.Parent:IsA("ScreenGui") then
        screensize = parent.Parent.AbsoluteSize
    else
        screensize = workspace.CurrentCamera and workspace.CurrentCamera.ViewportSize or Vector2.new(1920, 1080)
    end
    local absSize = frame.AbsoluteSize

    -- Clamp to screen
    local x = math.clamp(newPos.X.Offset, 0, screensize.X - absSize.X)
    local y = math.clamp(newPos.Y.Offset, 0, screensize.Y - absSize.Y)
    return UDim2.new(0, x, 0, y)
end

-- the dragging logic

local function dragToPosition(startInputPos, startFramePos, currInputPos, frame, bounds)
    local delta = currInputPos - startInputPos
    local newPos = UDim2.new(
        startFramePos.X.Scale,
        startFramePos.X.Offset + delta.X,
        startFramePos.Y.Scale,
        startFramePos.Y.Offset + delta.Y
    )
    if bounds then
        newPos = clampToScreen(frame, newPos)


Comments

1
Log in to join the conversation. Login
lumpiasallad's profile picture
lumpiasalladUploader2 years ago

here github link :https://github.com/lumpiasallad/MobileSuport_Drag_UI_Script-

1

Tags

More universal scripts

See all
Universal Script 📌
16
1
Approved 22 minutes ago
Universal Script 📌
13
2
Approved 36 minutes ago
Script hub
12
1
Approved 38 minutes ago
Script hub
5.1k
26.2k
Bumped 1 hour ago

Script hub

TLMenu