I am using FastCastRedux Module for this projectile.
the issue is that the projectile goes super buggy and glitchy when it is launched.
The code:
local sword2 = script.NoblePhantasms.Sword1:Clone()
sword2.Anchored = false
sword2.Transparency = 0
sword2.Material = “Metal”
sword2.ParticleEmitter2.Enabled = false
sword2.Color = Color3.new(0.45098, 0.45098, 0.45098)
sword2.Trail.Enabled = true
local FastCast = require(game.ReplicatedStorage.FastCastRedux)
FastCast.VisualizeCasts = false
local caster = FastCast.new()
local castParams = RaycastParams.new()
castParams.FilterType = Enum.RaycastFilterType.Blacklist
castParams.IgnoreWater = true
local ProjectileFolder = workspace:FindFirstChild("ProjectileFolder") or Instance.new("Folder", workspace)
ProjectileFolder.Name = "ProjectileFolder"
local castBehavior = FastCast.newBehavior()
castBehavior.RaycastParams = castParams
castBehavior.AutoIgnoreContainer = false
castBehavior.CosmeticBulletContainer = ProjectileFolder
castBehavior.CosmeticBulletTemplate = sword2
castParams.FilterDescendantsInstances = {player.Character,ProjectileFolder}
local function onLengthChanged(cast, lastPoint, direction, length, velocity, sword2)
if sword2 then
local bulletLength = sword2.Size.Z/2
local offset = CFrame.new(0, 0, -(length - bulletLength)) * CFrame.Angles(math.rad(-90),math.rad(-360),math.rad(360))
sword2.CFrame = CFrame.lookAt(lastPoint, lastPoint + direction):ToWorldSpace(offset)
end
end
local firepoint = player.Character:FindFirstChild("Caldibolg2").FirePoint
local function onRayHit(cast,result,veclocity,sword2)
local hit = result.Instance
local character = hit:FindFirstAncestorWhichIsA("Model")
if character and character:FindFirstChild("Humanoid") then
if hit.Name == "Baseplate" then
sword2.Anchored = true
end
print(hit.Parent.Name)
character.Humanoid:TakeDamage(8)
local weld = Instance.new("WeldConstraint",sword2)
weld.Part0 = sword2
weld.Part1 = hit
delay(1, function()
sword2.Material = "ForceField"
local ts = game:GetService("TweenService")
local info = TweenInfo.new(5,Enum.EasingStyle.Quint,Enum.EasingDirection.Out,0,false,0)
local goal = {
Transparency = 1;
Color = Color3.new(0, 0.666667, 1)
}
local tween = ts:Create(sword2,info,goal)
tween:Play()
sword2.ParticleEmitter2.Enabled = true
sword2.Trail.Enabled = false
delay(0.5, function()
sword2.ParticleEmitter2.Enabled = false
sword2.Trace:Destroy()
game.Debris:AddItem(sword2,1)
end)
end)
end
end
local origin = firepoint.WorldPosition
local direction = (extra1 - origin).Unit
caster:Fire(origin,direction,100,castBehavior)
caster.LengthChanged:Connect(onLengthChanged)
caster.RayHit:Connect(onRayHit)
video is little laggy at start.