MaxproGlitcher

Ligne entre les joueur .lua

Mar 8th, 2025
36
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.49 KB | None | 0 0
  1.  
  2. local Drawing = {}
  3. Drawing.__index = Drawing
  4.  
  5. function Drawing.new(type)
  6. if type == "Line" then
  7. local self = setmetatable({}, Drawing)
  8.  
  9. -- Create UI frame for the line
  10. self.Instance = Instance.new("Frame")
  11. self.Instance.AnchorPoint = Vector2.new(0.5, 0.5)
  12. self.Instance.BorderSizePixel = 0
  13. self.Instance.Parent = game.Players.LocalPlayer:WaitForChild("PlayerGui"):FindFirstChild("ScreenGui") or Instance.new("ScreenGui", game.Players.LocalPlayer:WaitForChild("PlayerGui"))
  14.  
  15. -- Default values
  16. self.From = Vector2.new(0, 0)
  17. self.To = Vector2.new(100, 100)
  18. self.Thickness = 5
  19. self.Color = Color3.new(1, 1, 1)
  20. self.Visible = true
  21.  
  22. -- Apply initial properties
  23. self:Update()
  24.  
  25. return self
  26. else
  27. error("Invalid Drawing type: " .. type)
  28. end
  29. end
  30.  
  31. function Drawing:Update()
  32. if not self.Instance then return end
  33. if not self.Visible then
  34. self.Instance.Visible = false
  35. return
  36. end
  37.  
  38. local distance = (self.To - self.From).Magnitude
  39. local direction = (self.To - self.From).Unit
  40. local angle = math.deg(math.atan2(direction.Y, direction.X))
  41.  
  42. self.Instance.Size = UDim2.new(0, distance, 0, self.Thickness)
  43. self.Instance.Position = UDim2.new(0, (self.From.X + self.To.X) / 2, 0, (self.From.Y + self.To.Y) / 2)
  44. self.Instance.Rotation = angle
  45. self.Instance.BackgroundColor3 = self.Color
  46. self.Instance.Visible = true
  47. end
  48.  
  49. function Drawing:Remove()
  50. if self.Instance then
  51. self.Instance:Destroy()
  52. self.Instance = nil
  53. end
  54. end
  55.  
  56. return Drawing
  57.  
Advertisement
Add Comment
Please, Sign In to add comment