Tips On Lowering Script Activity

Roblox 8_27_2023 7_47_39 PM

Can anyone give me Tips on how to lower a script
activity because this is just sad. This script is really useful but the
ping is horrible. It only has 600 lines of codes

2 Likes

I usually lower this by avoiding using while loops, using DRY and also using Never Nesting.

Other than that I’m sorry I couldn’t be of more help.

2 Likes

does using 1 while loop with everything mashed in it fix?

I would recommend finding a way around a while loop in general, they almost always take a lot of activity & USUALLY there are a lot better options

Love this command …

local rs = game:GetService("RunService")

rs.Stepped:Wait()
1 Like

So i put in most of the scripts in a local script and it lagged… a lot I think I found the fix. And now the Script way lower. But does for i,v in pairs do make game lag when it is using while loops?

Could you post your script?

for _,Trees in pairs(game:GetService('CollectionService'):GetTagged("WindShake")) do
	if #workspace.SFX.Sfxdetails.SoundInstances:GetChildren() <= 10 and script.Parent.Head.Position.Y <= 75 then
		local TS = game:GetService("TweenService")
		local Tween = TS:Create(workspace.SFX.Sfxdetails.WALLA.PLANES_01, TweenInfo.new(10, Enum.EasingStyle.Linear), {Volume =.3})
		Tween:Play()

		local TS = game:GetService("TweenService")
		local Tween = TS:Create(workspace.SFX.Sfxdetails.WALLA.QUIET_01, TweenInfo.new(5, Enum.EasingStyle.Linear), {Volume =.03})
		Tween:Play()
		workspace.Ambience.Values.Planes.Value = true
	else
		local TS = game:GetService("TweenService")
		local Tween = TS:Create(workspace.SFX.Sfxdetails.WALLA.PLANES_01, TweenInfo.new(10, Enum.EasingStyle.Linear), {Volume =0})
		Tween:Play()

		local TS = game:GetService("TweenService")
		local Tween = TS:Create(workspace.SFX.Sfxdetails.WALLA.QUIET_01, TweenInfo.new(10, Enum.EasingStyle.Linear), {Volume =0})
		Tween:Play()
		workspace.Ambience.Values.Planes.Value = false
	end
end

I want to put it in the while loop but it is causing the lag

(I moved this to local Script)

Is this your entire script? It shouldn’t be causing as much activity if this is actually your full script.

Actually nvm I found the fix Thank you for helping!

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.