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?
"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