Advertisement
IDontNoJustUseIt

Untitled

May 26th, 2020
125
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.13 KB | None | 0 0
  1. function dragify(Frame)
  2. dragToggle = nil
  3. dragSpeed = .1 -- You can edit this.
  4. dragInput = nil
  5. dragStart = nil
  6. dragPos = nil
  7.  
  8. function updateInput(input)
  9. Delta = input.Position - dragStart
  10. Position = UDim2.new(startPos.X.Scale, startPos.X.Offset + Delta.X, startPos.Y.Scale, startPos.Y.Offset + Delta.Y)
  11. game:GetService("TweenService"):Create(Frame, TweenInfo.new(.25), {Position = Position}):Play()
  12. end
  13.  
  14. Frame.InputBegan:Connect(function(input)
  15. if (input.UserInputType == Enum.UserInputType.MouseButton1 or input.UserInputType == Enum.UserInputType.Touch) then
  16. dragToggle = true
  17. dragStart = input.Position
  18. startPos = Frame.Position
  19. input.Changed:Connect(function()
  20. if (input.UserInputState == Enum.UserInputState.End) then
  21. dragToggle = false
  22. end
  23. end)
  24. end
  25. end)
  26.  
  27. Frame.InputChanged:Connect(function(input)
  28. if (input.UserInputType == Enum.UserInputType.MouseMovement or input.UserInputType == Enum.UserInputType.Touch) then
  29. dragInput = input
  30. end
  31. end)
  32.  
  33. game:GetService("UserInputService").InputChanged:Connect(function(input)
  34. if (input == dragInput and dragToggle) then
  35. updateInput(input)
  36. end
  37. end)
  38. end
  39.  
  40. dragify(script.Parent)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement