Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

help with a different way to run a script to reduce lag?

while true do

wait()

local part = script.Parent

if part.Velocity.Magnitude <= 3 then

end

if part.Velocity.Magnitude >= 4 then

script.Parent.BreakIt.Disabled = false

wait()

script.Disabled = true

end

end

because the changed function wont work with magnitude I used an infinite while loop to check the magnitude of its parent. the problem is I need dozens of these and after a certain point there is massive lag, what can I do to solve this?

1 comment

0

As I know you should not use this as a request site (I know I have been taken down for it)

1 answer

"while true do wait()

local part = script.Parent

if part.Velocity.Magnitude <= 3 then

end

if part.Velocity.Magnitude >= 4 then

script.Parent.BreakIt.Disabled = false

wait()

script.Disabled = true

end

end

because the changed function wont work with magnitude I used an infinite while loop to check the magnitude of its parent. the problem is I need dozens of these and after a certain point there is massive lag, what can I do to solve this?"

You can do something like this:

while true do wait(2) -- Adjust it to check only once in a while for i,v in pairs(game.Workspace:GetChildren()) -- Wherever the parts are located(if it has a specific path add it on and adjust it if you need to get a child of a child (:GetDescendats()) if v:IsA("ClassName") then if v.Velocity.Magnitude >= 4 then v.Parent.BreakIt.Disabled = false else return end end end end

2 comments

0

do glue surfaces cause lag? the reason I ask is because this script is paired with glued parts to create a dynamic physic system, because glue surfaces no longer break on their own after a force is applied I had to use this script to make them break, and now that im thinking about this, would having glued surfaces be causeing the lag?

0

Unsure. I don't really have lag problems since I try and clear debris and other things like simplifying scripts as much as possible ect.

This discussion is preserved as it was. New answers, comments, and votes are closed.