FastCast terminate cast


this is my current code.

i am trying to terminate the bullet when it times out (if bullet exists for more than 3 seconds then terminate it) but i keep getting this error

image
image

if anyone is smart enough to figure it out on the documentation thank you
https://etithespir.it/FastCastAPIDocs/fastcast-objects/activecast/

2 Likes

figured it out
activeCast:Terminate()

5 Likes

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ā€™

1 Like

It still gives me the same error:

ReplicatedStorage.Modules.FastCastRedux.ActiveCast:218: attempt to index nil with ā€˜DistanceCoveredā€™

I solved it with pcalls though, just to remove the error

1 Like

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.

1 Like