Advertisement
StefanBashkir

Untitled

Feb 15th, 2014
102
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.43 KB | None | 0 0
  1. local bar = script.Parent
  2. local scroller = script.Parent.ImageButton
  3. local increment = 1
  4. local last_mousebutton1downpos Vector2.new(0,0);
  5. local mouse = Game.Players.LocalPlayer:GetMouse();
  6.  
  7. local scrollerHeight = bar.AbsoluteSize.Y/script.Parent.Parent.SCROLL.AbsoluteSize.Y;
  8.  
  9. function GetScrollerClicked(mousex, mousey)
  10.     local x,y = mousex, mousey
  11.     local posx,posy,sizex,sizey = scroller.AbsolutePosition.X, scroller.AbsolutePosition.Y, scroller.AbsoluteSize.X, scroller.AbsoluteSize.Y;
  12.     if ( (x >= posx) and (x <= posx+sizex) ) and ( (y >= posy) and (y <= posy+sizey) ) then
  13.         return true
  14.     end
  15. end
  16.  
  17. function MousePassesDelta(mousex, mousey)
  18.     local Y_factor = 1;
  19.     local lasty = last_mousebutton1downpos.Y
  20.     local passedy = false;
  21.     local negativey = false;
  22.     if mousey > lasty then
  23.         if (mousey - lasty) >= increment then
  24.             passedy = true;
  25.             Y_factor = math.floor((mousey - lasty)/increment)
  26.         end
  27.     else
  28.         negativey = true;
  29.         if (lasty - mousey) >= increment then
  30.             passedy = true;
  31.             Y_factor = math.floor((lasty - mousey)/increment);
  32.         end
  33.     end
  34.    
  35.     return passedy, negativey, Y_factor;
  36. end
  37.  
  38. mouse.Button1Down:connect(function()
  39.     if GetScrollerClicked(mouse.X, mouse.Y) then
  40.         last_mousebutton1downpos = Vector2.new(mouse.X, mouse.Y);
  41.         mosemouve_connection = mouse.Move:connect(function()
  42.            
  43.         end)
  44.     end
  45. end)
  46.  
  47. mouse.Button1Up:connect(function()
  48.     pcall(function()
  49.         mousemove_connection:disconnect();
  50.     end)
  51. end)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement