Advertisement
Descaii

Physiks(Gui Version)

Mar 11th, 2014
520
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.94 KB | None | 0 0
  1. Player = game.Players.LocalPlayer
  2. repeat wait() until Player.PlayerGui
  3. Mouse = Player:GetMouse()
  4. Balls = {}
  5. Max = 500
  6. local UI = Instance.new("ScreenGui",Player.PlayerGui)
  7. local Bak = Instance.new("Frame",UI)
  8. Bak.Size = UDim2.new(1,0,1,0)
  9. Bak.BackgroundColor3 = Color3.new(0,0,0)
  10. function GetDistance(P1,P2)
  11. return math.sqrt((P1.X-P2.X)^2 + (P1.Y-P2.Y)^2)
  12. end
  13. function MakeBall()
  14. local Ball = {}
  15. Ball.P = Instance.new("Frame",UI)
  16. Ball.P.Size = UDim2.new(0,3,0,3)
  17. Ball.P.BorderSizePixel = 0
  18. Ball.P.Position = UDim2.new(0,100,0,100)
  19. Ball.P.ZIndex = 5
  20. Ball.Speed = math.random(50,300)/10000
  21. Ball.Dampen = math.random(900,1000)/1000
  22. Ball.Velocity = Vector2.new(math.random(-20,20),math.random(-20,20))
  23. Ball.Mass = 100
  24. table.insert(Balls,Ball)
  25. return Ball
  26. end
  27. Wind = Vector3.new(0,0,0)
  28. Mouse.Button1Down:connect(function()
  29. for i,v in pairs(Balls) do
  30. local Dis = GetDistance(Vector2.new(v.P.Position.X.Offset,v.P.Position.Y.Offset),Vector2.new(Mouse.X,Mouse.Y))
  31. if Dis < 300 then
  32. v.Velocity = v.Velocity*(10*((300-Dis)/300))
  33. end
  34. end
  35. end)
  36. game:GetService("RunService").Heartbeat:connect(function()
  37. for i,v in pairs(Balls) do
  38. local Dis = GetDistance(Vector2.new(v.P.Position.X.Offset,v.P.Position.Y.Offset),Vector2.new(Mouse.X,Mouse.Y))
  39. if Dis < 300 then
  40. local Offset = Vector2.new(Mouse.X-v.P.AbsolutePosition.X,Mouse.Y-v.P.AbsolutePosition.Y)
  41. v.Velocity = v.Velocity + Offset*Vector2.new((300-Dis)/300,v.Speed)
  42. v.P.BackgroundColor3 = Color3.new((math.abs(v.Velocity.X+v.Velocity.Y/2)/50)+0.5,50- (math.abs(v.Velocity.X+v.Velocity.Y/2)/50)+0.5,(math.abs(v.Velocity.X+v.Velocity.Y/2)/50)+0.5)
  43. v.P.Position = v.P.Position +UDim2.new(0,v.Velocity.X,0,v.Velocity.Y)
  44. v.Velocity = v.Velocity*Vector2.new(v.Dampen,v.Dampen)
  45. end
  46. end
  47. end)
  48. while wait(0.25) do
  49. if #Balls < Max then
  50. MakeBall()
  51. else
  52. local B = Balls[1]
  53. B.P:Destroy()
  54. table.remove(Balls,1)
  55. MakeBall()
  56. end
  57. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement