I been having this issue for some time now and it happens when I increase the speed of the projectile to be fast.
This video clearly shows that the projectile only appeared or trail started a few studs in front of the player character even though the origin was set to the player’s humanoidrootpart.
And in this module, I turned on the visualization and it shows that the ray cast worked perfectly fine, it started from the right origin but the projectile still appear in front of player character for a few studs.
This video has visualization turned on.
Fastcast/Raycast Module origin:
Module Direct Link:
Module Example Gun Direct Link:
This is the code that fires the projectile.(It’s really messy sorry LOL)
game.ReplicatedStorage.Emiya.CaldibolgRemote.OnServerEvent:Connect(function(player,extra1)
local mana = player.Character.Humanoid.Mana
local manacost = 5
if mana.Value > manacost then
mana.Value -= manacost
local WeaponList = script.NoblePhantasms
--player.Character.Humanoid:LoadAnimation(script.Animations.Bow1):Play()
local sword1 = WeaponList.Sword1:Clone()
sword1.Parent = player.Character
local weld1 = Instance.new("Weld",sword1)
weld1.Part0 = sword1
weld1.Part1 = player.Character["Right Arm"]
weld1.C0 = CFrame.new(0,-3.5,0)
weld1.C1 = CFrame.Angles(0,math.rad(-90),math.rad(180))
local ts = game:GetService("TweenService")
local info = TweenInfo.new(0.1,Enum.EasingStyle.Quint,Enum.EasingDirection.Out,0,false,0)
local goal = {
Transparency = 0;
Color = Color3.new(0.45098, 0.45098, 0.45098)
}
local tween = ts:Create(sword1,info,goal)
tween:Play()
local sfx = script.Sounds["stand summon sound"]:Clone()
sfx.Parent = player.Character.Head
sfx:Play()
game.Debris:AddItem(sfx,2)
delay(0.4, function()
sword1.Material = "Metal"
sword1.ParticleEmitter2.Enabled = false
sword1.Trace.Enabled = false
sword1:Destroy()
--welding cause the projectile to spin like shit so change later future paco
local sword2 = script.NoblePhantasms.Sword1:Clone()
sword2.Anchored = true
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 = true
local caster = FastCast.new()
local castParams = RaycastParams.new()
castParams.FilterType = Enum.RaycastFilterType.Exclude
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 fp = Instance.new("Attachment",player.Character.HumanoidRootPart)
fp.Name = "FirePoint"
fp.WorldCFrame = player.Character.HumanoidRootPart.CFrame
local firepoint = player.Character.HumanoidRootPart:FindFirstChild("FirePoint")
local function onRayHit(cast,result,veclocity,sword2)
local hit = result.Instance
if hit.className == "Part" or hit.className == "UnionOperation" or hit.className == "WedgePart" or hit.className == "MeshPart" then
sword2.Anchored = true
sword2["Rock Hit Dirt Impact 11 (SFX)"]:Play()
delay(1, function()
sword2.Material = "ForceField"
local ts = game:GetService("TweenService")
local info = TweenInfo.new(3,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
local character = hit:FindFirstAncestorWhichIsA("Model")
if character and character:FindFirstChild("Humanoid") then
if hit.Parent:FindFirstChild("Iframes") then return end
print(hit.Parent.Name)
local counterchecker = require(game.ReplicatedStorage.CounterCheckerModule)
counterchecker.Counter(hit.Parent,player.Character)
character.Humanoid:TakeDamage(7.5)
local np = player.Character.Humanoid.NP
local NPGiven = 5
if np.Value < 100 then
np.Value += NPGiven
end
local hitsfx = script.Sounds["Sword hit"]:Clone()
hitsfx.Parent = character.HumanoidRootPart
hitsfx:Play()
game.Debris:AddItem(hitsfx,2)
local weld = Instance.new("WeldConstraint",sword2)
weld.Part0 = sword2
weld.Part1 = hit
sword2.Anchored = false
local StunHandler = require(game.ReplicatedStorage.StunHandlerV2)
StunHandler.Stun(hit.Parent.Humanoid, 0.2, hit.Parent.CanAttack)
local stun = game.ReplicatedStorage.ExtraFolder.StunnedBillBoard:Clone()
stun.Parent = hit.Parent.Head
game.Debris:AddItem(stun,0.2)--change-->> stuns for 5 seconds
local vel = Instance.new("BodyVelocity")
vel.MaxForce = Vector3.new(50000,0,50000)
vel.Parent = hit.Parent.HumanoidRootPart
vel.Velocity = hit.Parent.HumanoidRootPart.CFrame.LookVector * -5
vel.Name = "SmallMoveVel"
game.Debris:AddItem(vel,.8)
delay(1, function()
sword2.Material = "ForceField"
local ts = game:GetService("TweenService")
local info = TweenInfo.new(3,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
game.Debris:AddItem(sword2,1)
--sword2.Trace:Destroy()
end)
end)
end
end
local origin = firepoint.WorldPosition
local direction = (extra1 - origin).Unit
caster:Fire(origin,direction,500,castBehavior)
game.Debris:AddItem(fp,1)
caster.LengthChanged:Connect(onLengthChanged)
caster.RayHit:Connect(onRayHit)
sword2:Destroy()
end)
end
end)
I even tested their example of the module which is the gun, but it remained the same issue when I increased the speed of the projectile.
I’m not a expert at using raycast, as I was only getting into it recently and in addition I rarely needed to use it.