I’m trying to create a tornado that uses body velocity to fling parts. I’ve tried adding a debounce so that when the tornado collides with a part, it doesn’t clone the velocity into said part a million times, however I haven’t been succesful and havent found anything online that was helpful. What can I do to solve my problem? (The block of code beneath is just a sample of the full script since most of the code presented basically repeats itself via elseif but with slight changes to some values).
local funnel = script.Parent
local destroy_weaker_parts = false
local overlapparams = OverlapParams.new()
local funnelsize = funnel.Size
while true do
wait()
local hitcontent = workspace:GetPartBoundsInBox(funnel.CFrame,Vector3.new(funnel.Size.X, funnelsize.Y, funnel.Size.Z), overlapparams)
for i, v in pairs(hitcontent) do
R1 = math.random(1,150)
R2 = math.random(1,150)
if funnel.Windspeed.Value >= 65 and funnel.Windspeed.Value < 86 then
if v.Name == "F0" then
v.Anchored = false
funnel.Damage.fling:Clone().Parent = v
funnel.Damage.fling2:Clone().Parent = v
if v:FindFirstChild("fling") then
v.fling.Velocity = Vector3.new(R1, 100, R2)
end
print("F0 Damage")
end
if v.Name == "Glass" then
funnel.glassbreak:Clone().Parent = v
v.glassbreak:Play()
v:Destroy()
end