Further FastCast Issues

I was able to fix the fast cast not firing a new caster for each ability. However, now I notice if all the skills are to be fired at the same time, it seems to overwrite the cast for each ability, which is not good. However, I’m puzzled as to how to go about reaching a solution. Here is the code:

	local CurrentPos = Obj.Position
	local ExplosionType = cast.UserData.ExplosionType
	local Skill = cast.UserData.SkillName
	local Player = cast.UserData.User
	local X = Obj
	local result = raycastResult
	local printthese = {ExplosionType,Skill,Player}
	print(unpack(printthese))
	if ExplosionType == "MagmaPunch" then
		local MagmaSpew = game.ReplicatedStorage:FindFirstChild("SkillParts"):FindFirstChild("MagmaImpact"):Clone()
		MagmaSpew.Position = result.Position
		Logic.TagSkill(MagmaSpew)
		MagmaSpew.Parent = Player
		game.ReplicatedStorage:FindFirstChild("ClientRemotes"):FindFirstChild("ExplosionVFX"):FireAllClients("Magma",MagmaSpew.CFrame)
		coroutine.wrap(function()
			game.ReplicatedStorage:FindFirstChild("ClientRemotes"):FindFirstChild("TweenHandler"):FireAllClients("Rotate",MagmaSpew,nil,nil,2,"Y")
			game.ReplicatedStorage:FindFirstChild("ClientRemotes"):FindFirstChild("TweenHandler"):FireAllClients("Expand",MagmaSpew,0.5,Vector3.new(35,3,35),nil,nil)
			task.wait(2)
			game.ReplicatedStorage:FindFirstChild("ClientRemotes"):FindFirstChild("TweenHandler"):FireAllClients("Expand",MagmaSpew,1,Vector3.new(0,0,0),nil,nil)
			task.wait(1)
			if MagmaSpew then
				MagmaSpew:Destroy()
			end
		end)()
		Logic.SkillMagDamage(Player,(25),X,Skill,nil,nil,"BurnSkill")
		local MagMax = 75
		for i,v in pairs(game.Players:GetChildren()) do
			if v.Character ~= nil then
				if (v.Character.HumanoidRootPart.Position-X.Position).Magnitude <= MagMax then
					game.ReplicatedStorage:FindFirstChild("CamShake"):FireClient(v)
				end
			end
		end
	end
	if ExplosionType == "LightBullet" then
		game.ReplicatedStorage:FindFirstChild("ClientRemotes"):FindFirstChild("ExplosionVFX"):FireAllClients("LightExplode",CFrame.new(result.Position))
		Logic.SkillMagDamage(Player,(25),X,Skill)
		local MagMax = 100
		for i,v in pairs(game.Players:GetChildren()) do
			if v.Character ~= nil then
				if (v.Character.HumanoidRootPart.Position-X.Position).Magnitude <= MagMax then
					game.ReplicatedStorage:FindFirstChild("CamShake"):FireClient(v)
				end
			end
		end
	end
	if ExplosionType == "LightKick" then
		game.ReplicatedStorage:FindFirstChild("ClientRemotes"):FindFirstChild("ExplosionVFX"):FireAllClients("LightExplode",CFrame.new(result.Position))
		Logic.SkillMagDamage(Player,(35),X,Skill)
		local MagMax = 100
		for i,v in pairs(game.Players:GetChildren()) do
			if v.Character ~= nil then
				if (v.Character.HumanoidRootPart.Position-X.Position).Magnitude <= MagMax then
					game.ReplicatedStorage:FindFirstChild("CamShake"):FireClient(v)
				end
			end
		end
	end
	if ExplosionType == "LightMirror" then
		game.ReplicatedStorage:FindFirstChild("ClientRemotes"):FindFirstChild("ExplosionVFX"):FireAllClients("LightExplode",CFrame.new(result.Position))
		Logic.SkillMagDamage(Player,(50),X,Skill)
		local MagMax = 100
		for i,v in pairs(game.Players:GetChildren()) do
			if v.Character ~= nil then
				if (v.Character.HumanoidRootPart.Position-X.Position).Magnitude <= MagMax then
					game.ReplicatedStorage:FindFirstChild("CamShake"):FireClient(v)
				end
			end
		end
	end
	if ExplosionType == "DarkBall" then
		game.ReplicatedStorage:FindFirstChild("ClientRemotes"):FindFirstChild("ExplosionVFX"):FireAllClients("DarkExplode",CFrame.new(result.Position))
		Logic.SkillMagDamage(Player,(25),X,Skill)
		local MagMax = 100
		for i,v in pairs(game.Players:GetChildren()) do
			if v.Character ~= nil then
				if (v.Character.HumanoidRootPart.Position-X.Position).Magnitude <= MagMax then
					game.ReplicatedStorage:FindFirstChild("CamShake"):FireClient(v)
				end
			end
		end
	end
	if ExplosionType == "BlackHole" then
		game.ReplicatedStorage:FindFirstChild("ClientRemotes"):FindFirstChild("ExplosionVFX"):FireAllClients("DarkExplode",X.CFrame)
		Logic.SkillMagDamage(Player,(75),X,Skill)
		local MagMax = 75
		for i,v in pairs(game.Players:GetChildren()) do
			if v.Character ~= nil then
				if (v.Character.HumanoidRootPart.Position-X.Position).Magnitude <= MagMax then
					game.ReplicatedStorage:FindFirstChild("CamShakeHeavy"):FireClient(v)
				end
			end
		end
	end
	if ExplosionType == "IceShard" then
		game.ReplicatedStorage:FindFirstChild("ClientRemotes"):FindFirstChild("ExplosionVFX"):FireAllClients("IceExplode",CFrame.new(result.Position))
		game.ReplicatedStorage:FindFirstChild("ClientRemotes"):FindFirstChild("Rocks"):FireAllClients(Player,X.Position,35,Vector3.new(6,3,3),nil,10,true,5)
		Logic.SkillMagDamage(Player,(35),X,Skill)
		for i,v in pairs(game.Workspace:GetChildren()) do
			if v:FindFirstChild("Humanoid") and v:FindFirstChild("HumanoidRootPart") and v:IsA("Model") and v ~= Player then
				if (v.HumanoidRootPart.Position-X.Position).Magnitude <= 35 then
					Logic.SkillHitEffect(v,"Ice",Player)
				end
			end
		end
		local MagMax = 35
		for i,v in pairs(game.Players:GetChildren()) do
			if v.Character ~= nil then
				if (v.Character.HumanoidRootPart.Position-X.Position).Magnitude <= MagMax then
					game.ReplicatedStorage:FindFirstChild("CamShake"):FireClient(v)
				end
			end
		end
	end
	if ExplosionType == "IceSpear" then
		game.ReplicatedStorage:FindFirstChild("ClientRemotes"):FindFirstChild("ExplosionVFX"):FireAllClients("IceExplode",CFrame.new(result.Position))
		game.ReplicatedStorage:FindFirstChild("ClientRemotes"):FindFirstChild("Rocks"):FireAllClients(Player,X.Position,35,Vector3.new(6,3,3),nil,10,true,5)
		Logic.SkillMagDamage(Player,(50),X,Skill)
		for i,v in pairs(game.Workspace:GetChildren()) do
			if v:FindFirstChild("Humanoid") and v:FindFirstChild("HumanoidRootPart") and v:IsA("Model") and v ~= Player then
				if (v.HumanoidRootPart.Position-X.Position).Magnitude <= 50 then
					Logic.SkillHitEffect(v,"Ice",Player)
				end
			end
		end
		local MagMax = 50
		for i,v in pairs(game.Players:GetChildren()) do
			if v.Character ~= nil then
				if (v.Character.HumanoidRootPart.Position-X.Position).Magnitude <= MagMax then
					game.ReplicatedStorage:FindFirstChild("CamShake"):FireClient(v)
				end
			end
		end
	end
	if ExplosionType == "SandBall" then
		local Explode = game.ReplicatedStorage:FindFirstChild("Explosions"):FindFirstChild("SandExplosion"):Clone()
		game.Debris:AddItem(Explode,1.75)
		Logic.TagSkill(Explode)
		Explode.Parent = Player
		Explode.CFrame = CFrame.new(X.Position)
		for i,v in pairs(Explode:GetDescendants()) do
			if v:IsA("ParticleEmitter") then
				v:Emit(v.Name)
			end
		end
		Logic.SkillMagDamage(Player,(25),Explode,Skill)
		local MagMax = 60
		for i,v in pairs(game.Players:GetChildren()) do
			if v.Character ~= nil then
				if (v.Character.HumanoidRootPart.Position-Explode.Position).Magnitude <= MagMax then
					game.ReplicatedStorage:FindFirstChild("CamShake"):FireClient(v)
				end
			end
		end
	end
	if ExplosionType == "FireBall" then
		game.ReplicatedStorage:FindFirstChild("ClientRemotes"):FindFirstChild("ExplosionVFX"):FireAllClients("FireExplode",CFrame.new(result.Position))
		Logic.SkillMagDamage(Player,(25),X,Skill,nil,nil,"BurnSkill")
		local MagMax = 100
		for i,v in pairs(game.Players:GetChildren()) do
			if v.Character ~= nil then
				if (v.Character.HumanoidRootPart.Position-X.Position).Magnitude <= MagMax then
					game.ReplicatedStorage:FindFirstChild("CamShake"):FireClient(v)
				end
			end
		end
	end
	if ExplosionType == "FireConqueror" then
		game.ReplicatedStorage:FindFirstChild("ClientRemotes"):FindFirstChild("ExplosionVFX"):FireAllClients("FireConquerorExplode",X.CFrame)
		Logic.SkillMagDamage(Player,(75),X,Skill,nil,nil,"BurnSkill")
		local MagMax = 75
		for i,v in pairs(game.Players:GetChildren()) do
			if v.Character ~= nil then
				if (v.Character.HumanoidRootPart.Position-X.Position).Magnitude <= MagMax then
					game.ReplicatedStorage:FindFirstChild("CamShakeHeavy"):FireClient(v)
				end
			end
		end
	end
	if ExplosionType == "LightningBall" then
		local Explode = game.ReplicatedStorage:FindFirstChild("Explosions"):FindFirstChild("LightningExplode"):Clone()
		game.Debris:AddItem(Explode,5)
		Logic.TagSkill(Explode)
		Explode.Parent = Player
		Explode.Position = X.CFrame.Position
		game.ReplicatedStorage:FindFirstChild("ClientRemotes"):FindFirstChild("Rocks"):FireAllClients(Player,Explode.Position,20,Vector3.new(5,3,3),nil,10,false,5)
		Logic.Sound(game.ReplicatedStorage:FindFirstChild("Sounds"):FindFirstChild("LightningLight"),Explode)
		Logic.SkillMagDamage(Player,(25),Explode,Skill)
		local MagMax = 100
		for i,v in pairs(game.Players:GetChildren()) do
			if v.Character ~= nil then
				if (v.Character.HumanoidRootPart.Position-Explode.Position).Magnitude <= MagMax then
					game.ReplicatedStorage:FindFirstChild("CamShake"):FireClient(v)
				end
			end
		end
		local TI = TweenInfo.new(0.15, Enum.EasingStyle.Quad, Enum.EasingDirection.In, 0)
		local Goal = {Scale = Vector3.new(15,15,15)}
		local Animation = TS:Create(Explode:FindFirstChild("Mesh"), TI, Goal)
		Animation:Play()
		coroutine.wrap(function()
			while Explode ~= nil and task.wait() do
				local TI = TweenInfo.new(0.15, Enum.EasingStyle.Quad, Enum.EasingDirection.In, 0)
				local Goal = {Scale = Vector3.new(25,25,25)}
				if Explode then
					local Animation = TS:Create(Explode:FindFirstChild("Mesh"), TI, Goal)
					Animation:Play()
				end
				task.wait(0.15)
				local TI = TweenInfo.new(0.15, Enum.EasingStyle.Quad, Enum.EasingDirection.In, 0)
				local Goal = {Scale = Vector3.new(15,15,15)}
				if Explode then
					local Animation = TS:Create(Explode:FindFirstChild("Mesh"), TI, Goal)
					Animation:Play()
				end
				task.wait(0.15)
			end
		end)()
		coroutine.wrap(function()
			Logic.Lightning((Explode.Position+Vector3.new(math.random(-15,-7),math.random(-15,-7),math.random(-15,-7))),(Explode.Position+Vector3.new(math.random(7,15),math.random(7,15),math.random(7,15))),15,Color3.new(0, 1, 1),Color3.new(0, 0.666667, 1),0.15,50,0.1,10)
		end)()
	end
	if ExplosionType == "ThunderBomb" then
		game.ReplicatedStorage:FindFirstChild("ClientRemotes"):FindFirstChild("ExplosionVFX"):FireAllClients("LightningExplode",X.CFrame)
		Logic.SkillMagDamage(Player,(42.5),X,Skill)
		local MagMax = 75
		for i,v in pairs(game.Players:GetChildren()) do
			if v.Character ~= nil then
				if (v.Character.HumanoidRootPart.Position-X.Position).Magnitude <= MagMax then
					game.ReplicatedStorage:FindFirstChild("CamShakeHeavy"):FireClient(v)
				end
			end
		end
	end
	if ExplosionType == "MochiHotShot" then
		game.ReplicatedStorage:FindFirstChild("ClientRemotes"):FindFirstChild("ExplosionVFX"):FireAllClients("MochiExplode",X.CFrame)
		Logic.SkillMagDamage(Player,(35),X,Skill,nil,nil,"BurnSkill")
		local MagMax = 75
		for i,v in pairs(game.Players:GetChildren()) do
			if v.Character ~= nil then
				if (v.Character.HumanoidRootPart.Position-X.Position).Magnitude <= MagMax then
					game.ReplicatedStorage:FindFirstChild("CamShake"):FireClient(v)
				end
			end
		end
	end
	if ExplosionType == "BisentoSphere" then
		game.ReplicatedStorage:FindFirstChild("ClientRemotes"):FindFirstChild("ExplosionVFX"):FireAllClients("BisentoSphereVFX",CFrame.new(result.Position))
		Logic.SkillMagDamage(Player,(50),X,Skill,nil,nil,nil,true,(Player.HumanoidRootPart.CFrame.UpVector*250))
		local MagMax = 150
		for i,v in pairs(game.Players:GetChildren()) do
			if v.Character ~= nil then
				if (v.Character.HumanoidRootPart.Position-X.Position).Magnitude <= MagMax then
					game.ReplicatedStorage:FindFirstChild("CamShake"):FireClient(v)
				end
			end
		end
	end
	if ExplosionType == "Takt" then
		ExplodeSFX(result.Position,game.ReplicatedStorage.Sounds:FindFirstChild("ExplosionSFX"))
		game.ReplicatedStorage:FindFirstChild("ClientRemotes"):FindFirstChild("ExplosionVFX"):FireAllClients("RockExplode",CFrame.new(result.Position))
		Logic.SkillMagDamage(Player,(35),X,Skill)
		local MagMax = 50
		for i,v in pairs(game.Players:GetChildren()) do
			if v.Character ~= nil then
				if (v.Character.HumanoidRootPart.Position-X.Position).Magnitude <= MagMax then
					game.ReplicatedStorage:FindFirstChild("CamShake"):FireClient(v)
				end
			end
		end
	end
	if ExplosionType == "MeteorShower" then
		game.ReplicatedStorage:FindFirstChild("ClientRemotes"):FindFirstChild("ExplosionVFX"):FireAllClients("GravityExplode",CFrame.new(result.Position))
		Logic.SkillMagDamage(Player,(25),X,Skill)
		local MagMax = 100
		for i,v in pairs(game.Players:GetChildren()) do
			if v.Character ~= nil then
				if (v.Character.HumanoidRootPart.Position-X.Position).Magnitude <= MagMax then
					game.ReplicatedStorage:FindFirstChild("CamShake"):FireClient(v)
				end
			end
		end
	end
	if ExplosionType == "GrandMeteor" then
		game.ReplicatedStorage:FindFirstChild("ClientRemotes"):FindFirstChild("ExplosionVFX"):FireAllClients("GravityExplode",CFrame.new(result.Position))
		Logic.SkillMagDamage(Player,(50),X,Skill)
		local MagMax = 100
		for i,v in pairs(game.Players:GetChildren()) do
			if v.Character ~= nil then
				if (v.Character.HumanoidRootPart.Position-X.Position).Magnitude <= MagMax then
					game.ReplicatedStorage:FindFirstChild("CamShake"):FireClient(v)
				end
			end
		end
	end
	if ExplosionType == "KissPistol" then
		game.ReplicatedStorage:FindFirstChild("ClientRemotes"):FindFirstChild("ExplosionVFX"):FireAllClients("LoveExplode",CFrame.new(result.Position))
		Logic.SkillMagDamage(Player,(25),X,Skill)
		local MagMax = 100
		for i,v in pairs(game.Players:GetChildren()) do
			if v.Character ~= nil then
				if (v.Character.HumanoidRootPart.Position-X.Position).Magnitude <= MagMax then
					game.ReplicatedStorage:FindFirstChild("CamShake"):FireClient(v)
				end
			end
		end
	end
	if ExplosionType == "PawThrust" then
		game.ReplicatedStorage:FindFirstChild("ClientRemotes"):FindFirstChild("ExplosionVFX"):FireAllClients("Paw",X.CFrame)
		Logic.SkillMagDamage(Player,(25),X,Skill)
		local MagMax = 50
		for i,v in pairs(game.Players:GetChildren()) do
			if v.Character ~= nil then
				if (v.Character.HumanoidRootPart.Position-X.Position).Magnitude <= MagMax then
					game.ReplicatedStorage:FindFirstChild("CamShake"):FireClient(v)
				end
			end
		end
	end
	if ExplosionType == "PawCannon" then
		game.ReplicatedStorage:FindFirstChild("ClientRemotes"):FindFirstChild("ExplosionVFX"):FireAllClients("PawCannon",X.CFrame)
		Logic.SkillMagDamage(Player,(50),X,Skill)
		local MagMax = 50
		for i,v in pairs(game.Players:GetChildren()) do
			if v.Character ~= nil then
				if (v.Character.HumanoidRootPart.Position-X.Position).Magnitude <= MagMax then
					game.ReplicatedStorage:FindFirstChild("CamShakeHeavy"):FireClient(v)
				end
			end
		end
	end
	if ExplosionType == "AirBladeKick" then
		game.ReplicatedStorage:FindFirstChild("ClientRemotes"):FindFirstChild("ExplosionVFX"):FireAllClients("AirBladeExplode",CFrame.new(result.Position))
		Logic.SkillMagDamage(Player,(50),X,Skill)
		local MagMax = 100
		for i,v in pairs(game.Players:GetChildren()) do
			if v.Character ~= nil then
				if (v.Character.HumanoidRootPart.Position-X.Position).Magnitude <= MagMax then
					game.ReplicatedStorage:FindFirstChild("CamShakeHeavy"):FireClient(v)
				end
			end
		end
	end
end

The cast outside of the function:


local Caster = FC.new()
local Behavior = FC.newBehavior()

Cast Example:

		params.FilterType = Enum.RaycastFilterType.Blacklist
		params.FilterDescendantsInstances = {game.Workspace.Debris,APlayer,X}
		local Origin = X.Position
		local Direct = (Aim.Position-Origin).Unit
		Behavior.RaycastParams = params
		local FireCast = Caster:Fire(Origin, Direct, 150, Behavior)
		FireCast.RayInfo.CosmeticBulletObject = X
		FireCast.UserData.User = APlayer
		FireCast.UserData.ExplosionType = "MochiHotShot"
		FireCast.UserData.SkillName = Skill