Advertisement
tyridge77

Untitled

Aug 29th, 2015
133
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.28 KB | None | 0 0
  1. localPlayer = game:getService("Players").localPlayer
  2. playerGui = localPlayer:waitForChild("PlayerGui")
  3. mouse = localPlayer:getMouse()
  4.  
  5. function checkMouseEntered(rect)
  6. local mousePosition = CFrame.new(mouse.X, mouse.Y, 0)
  7. local rectPosition = CFrame.new(rect.Position.X.Offset+rect.Size.X.Offset/2, rect.Position.Y.Offset+rect.Size.Y.Offset/2, 0)*CFrame.Angles(0, 0, math.rad(rect.Rotation))
  8. local relativeMouse = mousePosition:toObjectSpace(rectPosition)
  9. if relativeMouse.X > 0 and relativeMouse.X < rect.Size.X.Offset and relativeMouse.Y > 0 and relativeMouse.Y < rect.Size.Y.Offset then
  10. return true, UDim2.new(0, mousePosition.X, 0, mousePosition.Y)
  11. else
  12. return false, UDim2.new(0, mousePosition.X, 0, mousePosition.Y)
  13. end
  14. end
  15.  
  16. thing = Instance.new("ScreenGui", playerGui)
  17.  
  18. rect = Instance.new("Frame", thing)
  19. rect.Size = UDim2.new(0, 600, 0, 300)
  20. rect.Position = UDim2.new(0, 500, 0, 400)
  21. rect.Rotation = 35
  22.  
  23. mouse.Move:connect(function()
  24. local value, pos = checkMouseEntered(rect)
  25. print(value, pos)
  26. if value == false then
  27. local newThing = Instance.new("Frame", thing)
  28. newThing.Size = UDim2.new(0, 5, 0, 5)
  29. newThing.Position = pos
  30. newThing.BackgroundColor3 = Color3.new(1, 0, 0)
  31. end
  32. end)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement