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

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

Asked by 5 years ago
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?

0
As I know you should not use this as a request site (I know I have been taken down for it) aandmprogameing 52 — 5y

1 answer

Log in to vote
0
Answered by 5 years ago

"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

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? mantorok4866 201 — 5y
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. ItsBankai 31 — 5y
Ad

Answer this question