Universal Script 📌
11.8k Views
56 Executions

OpenSource Draggable Gui

Universal Script 📌
CMDS
CMDSPublished 10
3 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

Draggable gui thingy (made by PawsThePaw)

View Raw
local UserInputService = game:GetService("UserInputService")
local frame = PutYourFrameNameHere
local dragging
local dragInput
local dragStart
local startPos
local function update(input)
        local delta = input.Position - dragStart
		frame.Position = UDim2.new(startPos.X.Scale, startPos.X.Offset + delta.X, startPos.Y.Scale, startPos.Y.Offset + delta.Y)
end
frame.InputBegan:Connect(function(input)
        if input.UserInputType == Enum.UserInputType.MouseButton1 or input.UserInputType == Enum.UserInputType.Touch then
			dragging = true
			dragStart = input.Position
			startPos = frame.Position
                               input.Changed:Connect(function()
				if input.UserInputState == Enum.UserInputState.End then
					dragging = false
				end
			end)
		end
end)
frame.InputChanged:Connect(function(input)
        if input.UserInputType == Enum.UserInputType.MouseMovement or input.UserInputType == Enum.UserInputType.Touch then
			dragInput = input
		end
	end)
UserInputService.InputChanged:Connect(function(input)
		if input == dragInput and dragging then
			update(input)
		end
end)



Comments

0
Log in to join the conversation. Login
No comments yet. Be the first!

Tags

More universal scripts

See all
Universal Script 📌
6.1k
17.8k
Bumped 3 hours ago
Key System
Universal Script 📌
532.8k
336.7k
Bumped 5 hours ago
Script hub
2.6k
2.2k
Bumped 6 hours ago
Key System
Universal Script 📌
542
38
Approved 6 hours ago