I'm trying to make a tween effect happen on the whole map, so I did it and it was very laggy in a large map. How would I make it that it wouldn't lag as much as it does?
script:
local debounce = false
script.Parent.MouseButton1Down:Connect(function()
if debounce == false then
debounce = true
for _, v in pairs(workspace.ThingsGone:GetDescendants()) do
if v:IsA("BasePart") or v:IsA("MeshPart") or v:IsA("Part") then
workspace.KingCrimson:Play()
spawn(function()
local newv = v:Clone()
newv.Parent = workspace.newThings
newv.CanCollide = false
v.Transparency = 1
local ts = game:GetService("TweenService")
local tsinfo = TweenInfo.new(1.4, Enum.EasingStyle.Quad, Enum.EasingDirection.InOut, 0, false, 0)
local tsinfo2 = TweenInfo.new(.05, Enum.EasingStyle.Quad, Enum.EasingDirection.InOut)
local partProp = {Size = Vector3.new(0, 0, 0);
Orientation = Vector3.new(13,13,13);
Transparency = 1
}
local guiProp = {Position = UDim2.new(1, 0, 0, 0)}
local tween = ts:Create(newv, tsinfo, partProp)
local tween2 = ts:Create(newv, TweenInfo.new(0), {Transparency = 1})
local frame = game.Players.LocalPlayer.PlayerGui.ScreenGui.ImageLabel
local frame2 = game.Players.LocalPlayer.PlayerGui.ScreenGui2.ImageLabel
local tween5 = ts:Create(frame2, tsinfo2, guiProp)
local tween3 = ts:Create(frame, tsinfo2, guiProp)
tween:Play()
tween3:Play()
wait(1.5)
tween2:Play()
wait(3)
workspace.KingCrimson:Stop()
workspace.TimeSkip:Play()
tween5:Play()
newv:Destroy()
v.Transparency = 0
wait(.4)
frame.Position = UDim2.new(-1,0,0,0)
frame2.Position = UDim2.new(-1,0,0,0)
end)
end
end
end
end)
meant to be local btw. Also the tweens wont play all at the same time, which is probably due to lag. Another thing, the tweens playing on the frame (which is a gui) repeats a bunch when v.Transparency is visible again. Any help will be appreciated.

1 comment
What do you mean by laggy, exactly?