local pull = rs2.Heartbeat:Connect(function()
for _, obj in ipairs(breakables) do
local distance = (tornado.Position - obj.Position).Magnitude
if obj:IsA("BasePart") and obj.Anchored == false and distance <= 45 then
local dir = ( tornado.Position - obj.Position)
local force = math.clamp(obj.Mass,30,40)
local rotation = math.clamp(obj.Mass,20,30)
obj.AssemblyLinearVelocity = dir.Unit * force
obj.AssemblyAngularVelocity = dir.Unit * rotation
elseif obj.Anchored == true and distance <= 45 then
obj.Anchored = false
end
end
``` how could i optimize this?, it lags alot since there is alot of parts but i dont want to loose smoothness, it is only a part of the code but its only the necessary ig
#game lagging
1 messages · Page 1 of 1 (latest)