Universal Script πŸ“Œ
2.3k Views
46 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
Script hub
33.1k
298.2k
Bumped 2 hours ago
Script hub
23.7k
5.2k
Bumped 2 hours ago
Key System
Paid
High QualityΒ Offering
Universal Script πŸ“Œ
227
600
Bumped 3 hours ago
Universal Script πŸ“Œ
1.6k
30.3k
Bumped 3 hours ago
Script hub
4.1M
558.8k
Bumped 3 hours ago
Key System

Script hub

Hall of Fame #3

Verified script badgeOverflow 35 Supported Games

Script hub
5.5k
29.1k
Bumped 4 hours ago
Key System