Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- Compiled with https://roblox-ts.github.io v0.2.14
- -- November 9, 2019, 7:14 PM Bolivia Time
- local TS = require(game:GetService("ReplicatedStorage"):WaitForChild("rbxts_include"):WaitForChild("RuntimeLib"));
- local VIEWPORT_SIZE;
- local _0 = TS.import(TS.getModule("services"));
- local Players, RunService, Workspace = _0.Players, _0.RunService, _0.Workspace;
- local Particle;
- do
- Particle = setmetatable({}, {
- __tostring = function() return "Particle" end;
- });
- Particle.__index = Particle;
- function Particle.new(...)
- local self = setmetatable({}, Particle);
- self:constructor(...);
- return self;
- end;
- function Particle:constructor(Parent)
- self.bounce = 0.9;
- self.gravity = 0.4;
- self.object = Instance.new("Frame");
- self.object.Parent = Parent;
- self.object.Size = UDim2.new(UDim.new(0, 10), UDim.new(0, 10));
- self.object.BackgroundColor3 = Color3.new(0, 0, 0);
- self.x_pos = 10;
- self.y_pos = 10;
- self.prev_xpos = 0;
- self.prev_ypos = 0;
- end;
- function Particle:updatePoint()
- local vx = self.x_pos - self.prev_xpos;
- local vy = self.y_pos - self.prev_ypos;
- self.prev_xpos = self.x_pos;
- self.prev_ypos = self.y_pos;
- self.x_pos = self.x_pos + (vx);
- self.y_pos = self.y_pos + (vy);
- self.y_pos = self.y_pos + (self.gravity);
- if self.x_pos > VIEWPORT_SIZE.X then
- self.x_pos = VIEWPORT_SIZE.X;
- self.prev_xpos = self.x_pos + (vx * self.bounce);
- elseif self.x_pos < 1 / 60 then
- self.prev_xpos = self.x_pos + (vx * self.bounce);
- end;
- if self.y_pos > VIEWPORT_SIZE.Y then
- self.y_pos = VIEWPORT_SIZE.Y;
- self.prev_ypos = self.y_pos + (vy * self.bounce);
- elseif self.y_pos < 1 / 60 then
- self.prev_ypos = self.y_pos + (vy * self.bounce);
- end;
- end;
- function Particle:registerPont()
- self.object.Position = UDim2.new(UDim.new(0, self.x_pos), UDim.new(0, self.y_pos));
- end;
- end;
- local player = Players.LocalPlayer;
- local camera = Workspace.CurrentCamera;
- local main_ui = player:WaitForChild("PlayerGui"):WaitForChild("Main");
- local frame = main_ui:FindFirstChild("Frame");
- local particle = Particle.new(frame);
- VIEWPORT_SIZE = camera.ViewportSize;
- local function update()
- particle:updatePoint();
- particle:registerPont();
- end;
- local function sortOrderIn(Object)
- TS.array_forEach(Object, function(element, index, array)
- element.Name = "Particle_" .. tostring(index + 1);
- end);
- end;
- RunService.RenderStepped:Connect(update);
- sortOrderIn(frame:GetChildren());
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement