Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local API = {}
- function API:Load()
- local other = {}
- function other:CustomDrag(Object, Delay)
- local UserInputService = game:GetService("UserInputService")
- local gui = Object
- local dragging
- local dragInput
- local dragStart
- local startPos
- local function update(input)
- local delta = input.Position - dragStart
- wait(tonumber(Delay))
- gui.Position = UDim2.new(startPos.X.Scale, startPos.X.Offset + delta.X, startPos.Y.Scale, startPos.Y.Offset + delta.Y)
- end
- gui.InputBegan:Connect(function(input)
- if input.UserInputType == Enum.UserInputType.MouseButton1 or input.UserInputType == Enum.UserInputType.Touch then
- dragging = true
- dragStart = input.Position
- startPos = gui.Position
- input.Changed:Connect(function()
- if input.UserInputState == Enum.UserInputState.End then
- dragging = false
- end
- end)
- end
- end)
- gui.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)
- end
- function other:OnButtonPress(Button, Callback)
- if Button:IsA("TextButton") then
- Button.MouseButton1Click:Connect(function()
- Callback()
- end)
- elseif Button:IsA("ImageButton") then
- Button.MouseButton1Click:Connect(function()
- Callback()
- end)
- else
- warn("Please make sure you define a button!")
- end
- end
- return other;
- end
- return API;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement