Hey! Im also having an error when I terminate the cast even using cast.Terminate(cast). Here is the code:
-- On Ray Length Changed teleport bullet with Ray
local function OnLengthChanged(cast, lastPoint, direction, length, velocity, bullet)
if bullet then
local bulletLength = bullet.Size.Z/2
local offset = CFrame.new(0, 0, -(length - bulletLength))
bullet.CFrame = CFrame.lookAt(lastPoint, lastPoint + direction):ToWorldSpace(offset)
local GotTarget = AcquireTarget(bullet)
if GotTarget then -- Terminate Bullet
print("Got It Close")
cast.Terminate(cast)
end
end
end
Caster.LengthChanged:Connect(OnLengthChanged)
And this is the error I get:
ReplicatedStorage.Modules.FastCastRedux.ActiveCast:217: attempt to index nil with āDistanceCoveredā
I used a Debounce to see if that can run it once. But it doesnt make a difference and the print statement (āGot It Closeā) still prints one time even without the debounce.