Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
1

How would I make this script not lag the entire game?

Asked by
atmxe 17
3 years ago
Edited 3 years ago

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.

0
What do you mean by laggy, exactly? Benbebop 1049 — 3y

1 answer

Log in to vote
0
Answered by 3 years ago

there is no way to clear lag, this is a result of the rob lox hardware servers themselves or your client side being trash, and the best result with a script is doing the least amount of work with the least amount of time, so i see waits every where, and i dont see anything that could make it faster, its impossible, but, i think roblox is multi threaded so you could probably tween a bunch of things at once but still the rendering will get laggy and also the game itself wont be able to handle as much no matter what you do.

0
Alright thanks for the input. atmxe 17 — 3y
0
no problem AlexanderYar 788 — 3y
Ad

Answer this question