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

How To Fix Scripts Overflowing Into Parts?

Asked by 4 years ago

So I have a bomb part I'm working on (I promise I'm not crazy lol) and it has a sort of "shock wave" ring coming out of it, which breaks joints as it passes through parts. However, as the wave passes through the parts, it lags incredibly quickly as the parts are having around 10-15 scripts per part since the part insert script isn't limited.

Below is the inserting script for the shockwave.

Does anybody know a way to limit 1 script per part? Or any way to reduce this lag? Thanks!

wait(1)
local part = script.Parent

local function onPartTouched(otherPart)
        local a = game.ServerStorage.BodyForce:Clone()
        a.Parent = otherPart
        otherPart.BodyForce.Fling_Force.Disabled = false
        otherPart:BreakJoints()
end

part.Touched:Connect(onPartTouched)

Answer this question