Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --//ALL CREDITS GO TO Google Chrome\\--
- local players = game:service('Players');
- local player = players.LocalPlayer;
- local mouse = player:GetMouse();
- local run = game:service('RunService');
- local stepped = run.Stepped;
- draggable = function(obj)
- spawn(function()
- obj.Active = true;
- local minitial;
- local initial;
- local isdragging;
- obj.InputBegan:Connect(function(input)
- if input.UserInputType == Enum.UserInputType.MouseButton1 or input.UserInputType == Enum.UserInputType.Touch then
- isdragging = true;
- minitial = input.Position;
- initial = obj.Position;
- local con;
- con = stepped:Connect(function()
- if isdragging then
- local delta = Vector3.new(mouse.X, mouse.Y, 0) - minitial;
- obj.Position = UDim2.new(initial.X.Scale, initial.X.Offset + delta.X, initial.Y.Scale, initial.Y.Offset + delta.Y);
- else
- con:Disconnect();
- end;
- end);
- input.Changed:Connect(function()
- if input.UserInputState == Enum.UserInputState.End then
- isdragging = false;
- end;
- end);
- end;
- end);
- end)
- end;
- draggable(script.Parent)
Add Comment
Please, Sign In to add comment