I have ~10 balloons that float around a room and bounce off the walls. Every few minutes or so, Studio crashes for about 20-30 secs and causes this error repeatedly on some balloons, not all. Sometimes it’s about ~3 different balloons but keeps spamming the error on one specific balloon many times if that makes sense.
Script:
function Shoot()
local maxDistance = 999999999999999
local curDistance = 0
local stepDistance = .02
local stepWait = 0
local currentPos = script.Parent.Position
local currentNormal = script.Parent.CFrame.LookVector
local function Step(overrideDistance)
local params = RaycastParams.new() --Line 14
local direction = currentNormal * (overrideDistance or stepDistance)
params.FilterType = Enum.RaycastFilterType.Exclude
params.FilterDescendantsInstances = {script.Parent}
local result = workspace:Raycast(currentPos, direction)
local pos
local currentPos2 = Vector3.new(currentPos.X, 9.875, currentPos.Z)
if result then
pos = result.Position
else
pos = currentPos2 + direction
end
script.Parent.CFrame = CFrame.new(currentPos2:Lerp(pos, 0), pos)
local oldPos = currentPos
currentPos = pos
if result then
-- r = d - 2(d DOT n)n
local norm = result.Normal
local reflect = (currentNormal - (2 * currentNormal:Dot(norm) * norm))
currentNormal = reflect
Step(stepDistance - (pos - oldPos).Magnitude) --Line 42
local initialY = 9.875
script.Parent.Position = Vector3.new(script.Parent.Position.x, initialY, script.Parent.Position.z)
return
end
curDistance = (curDistance + (pos - oldPos).Magnitude)
-- Recurse if max distance not reached:
if curDistance < maxDistance then
task.wait(stepWait)
Step() --Line 62
end
end
Step()
warn("Balloon stop moving")
end
local randomy = math.random(0,360)
script.Parent.Orientation = Vector3.new(0,randomy,0)
Shoot() --firee!!!!!!
Unsure of why it happens and can’t really find anything online. Help please n thanks.
