When the glass shards particle effects appear, the game lags.How do I reduce the lag?
local NTRi = math.random(10,25)
for i=1,NTRi,1 do
local function DTri()
task.wait(math.random(1,3)/1000)
local Tri = CGui.Triangle:Clone()
Tri.Size = UDim2.new(math.random(1,2)/10,0,math.random(1,2)/10,0)
Tri.Parent = CGui
Tri.Visible = true
Tri.Rotation = math.random(-360,360)
local DTime = math.random(1,25/10)
game.Debris:AddItem(Tri,DTime)
local TInfo = TweenInfo.new(
math.random(8, 10),
Enum.EasingStyle.Exponential,
Enum.EasingDirection.Out,
0,
false
)
local TweenInfoSize = TweenInfo.new(
math.random(2, 4),
Enum.EasingStyle.Exponential
)
local EndPosition = UDim2.new(math.random(-10,10), math.random(-100,100), math.random(-10,10), math.random(-100,100)) -- Final Pos (bottom)
local EndSize = UDim2.new(0, 0, 0, 0) -- End Size (0)
local TweenSize = game:GetService("TweenService"):Create(Tri, TweenInfoSize, {Size = EndSize})
local TweenPosition = game:GetService("TweenService"):Create(Tri, TInfo, {Position = EndPosition})
TweenSize:Play()
TweenPosition:Play()
game.Debris:AddItem(TweenSize,DTime)
game.Debris:AddItem(TweenPosition,DTime)
end
coroutine.wrap(DTri)()
end