Problem with FastCast

  1. I Want to make a shooting spell and I am making it a projectile.

  2. The projectile does not work correctly, When I aim at a certain direction, It stop working, It either glitch or either the projectile does not exist.

local RunService = game:GetService("RunService")
local Debris = game:GetService("Debris")
local TweenService = game:GetService("TweenService")
local FastCast = require(script.FastCastRedux)
local Caster = FastCast.new()

Caster.LengthChanged:Connect(function(casterThatFired, lastPoint, rayDir, displacement, segmentVelocity, cosmeticBulletObject)
	local Position = lastPoint + (rayDir * displacement)
	
	cosmeticBulletObject.Position = Position
end)

Caster.RayHit:Connect(function(casterThatFired, result, segmentVelocity, cosmeticBulletObject)
	
end)

local Spells = {}

function Spells:Shoot(Player: Player, Tool: Tool, MousePosition: Vector3)
	
	local Character = Player.Character or Player.CharacterAdded:Wait()
	local Handle: Part = Tool.Handle 
	local Direction = (MousePosition - Handle.Position).Unit
	local DamagePart = game.ServerStorage["Damage part."]:Clone()
	
	local RaycastParameters = RaycastParams.new()
	RaycastParameters.FilterType = Enum.RaycastFilterType.Exclude
	RaycastParameters.FilterDescendantsInstances = {Character}
	
	local FastCastBehavoiur = FastCast.newBehavior()
	FastCastBehavoiur.MaxDistance = 150
	FastCastBehavoiur.RaycastParams = RaycastParameters
	FastCastBehavoiur.CosmeticBulletTemplate = game.ReplicatedStorage["Visual effects."].Projectile
	FastCastBehavoiur.CosmeticBulletContainer = workspace
	
	Caster:Fire(Tool["Build."].Part.Position, Direction, 100, FastCastBehavoiur)
	
end

return Spells

This script is a cut part of a much larger script.

Try putting prints at the start of key functions to see if they are firing. That rules out some if statement/ logic ending the execution to early

Are you sure MousePosition is valid at all times?

Problem solved, I found that there is a linear velocity in the projectile I forgot to delete and it has some effects on it.

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.