Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Player = game.Players.LocalPlayer
- repeat wait() until Player.PlayerGui
- Mouse = Player:GetMouse()
- Balls = {}
- Max = 500
- local UI = Instance.new("ScreenGui",Player.PlayerGui)
- local Bak = Instance.new("Frame",UI)
- Bak.Size = UDim2.new(1,0,1,0)
- Bak.BackgroundColor3 = Color3.new(0,0,0)
- function GetDistance(P1,P2)
- return math.sqrt((P1.X-P2.X)^2 + (P1.Y-P2.Y)^2)
- end
- function MakeBall()
- local Ball = {}
- Ball.P = Instance.new("Frame",UI)
- Ball.P.Size = UDim2.new(0,3,0,3)
- Ball.P.BorderSizePixel = 0
- Ball.P.Position = UDim2.new(0,100,0,100)
- Ball.P.ZIndex = 5
- Ball.Speed = math.random(50,300)/10000
- Ball.Dampen = math.random(900,1000)/1000
- Ball.Velocity = Vector2.new(math.random(-20,20),math.random(-20,20))
- Ball.Mass = 100
- table.insert(Balls,Ball)
- return Ball
- end
- Wind = Vector3.new(0,0,0)
- Mouse.Button1Down:connect(function()
- for i,v in pairs(Balls) do
- local Dis = GetDistance(Vector2.new(v.P.Position.X.Offset,v.P.Position.Y.Offset),Vector2.new(Mouse.X,Mouse.Y))
- if Dis < 300 then
- v.Velocity = v.Velocity*(10*((300-Dis)/300))
- end
- end
- end)
- game:GetService("RunService").Heartbeat:connect(function()
- for i,v in pairs(Balls) do
- local Dis = GetDistance(Vector2.new(v.P.Position.X.Offset,v.P.Position.Y.Offset),Vector2.new(Mouse.X,Mouse.Y))
- if Dis < 300 then
- local Offset = Vector2.new(Mouse.X-v.P.AbsolutePosition.X,Mouse.Y-v.P.AbsolutePosition.Y)
- v.Velocity = v.Velocity + Offset*Vector2.new((300-Dis)/300,v.Speed)
- 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)
- v.P.Position = v.P.Position +UDim2.new(0,v.Velocity.X,0,v.Velocity.Y)
- v.Velocity = v.Velocity*Vector2.new(v.Dampen,v.Dampen)
- end
- end
- end)
- while wait(0.25) do
- if #Balls < Max then
- MakeBall()
- else
- local B = Balls[1]
- B.P:Destroy()
- table.remove(Balls,1)
- MakeBall()
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement