So I was creating an OTS gun system for R15 and this weird issue popped up.
Bullets that should travel after being fired don’t actually travel.
All of the bounding boxes are bullet models that never fired.
I am firing the bullets using this function here:
local cast = fastcastredux.new()
local holder_folder = workspace:FindFirstChild("CONTAINER_FASC") or Instance.new("Folder",workspace)
holder_folder.Name = "CONTAINER_FASC"
local rayp = RaycastParams.new()
rayp.FilterType = Enum.RaycastFilterType.Exclude
rayp.IgnoreWater = true
local raybehavior = fastcastredux.newBehavior()
raybehavior.Acceleration = Vector3.new(0,-(workspace.Gravity/40),0)
raybehavior.RaycastParams = rayp
raybehavior.CosmeticBulletTemplate = game:GetService("ServerStorage").gun_bullets[tool.Name]:WaitForChild("b"):Clone()
raybehavior.CosmeticBulletContainer = holder_folder
raybehavior.MaxDistance = 1000
function fireCast(cf)
if g_settings.Ammo.Value > 0 and equipped then
local cstorigin = tool.Handle.fire.WorldPosition
local ndr = (cf-cstorigin).Unit
local directionalCF = CFrame.new(Vector3.new(), ndr)
local direction = (directionalCF * CFrame.fromOrientation(0, 0, rng:NextNumber(0, tau)) * CFrame.fromOrientation(math.rad(rng:NextNumber(-g_settings.Spread.Value,g_settings.Spread.Value)), 0, 0)).LookVector
if ricochet then
raybehavior.CanPierceFunction = CanRayPierce
end
print("firing")
cast:Fire(cstorigin,direction,1000,raybehavior)
print("fired")
g_settings.Ammo.Value = g_settings.Ammo.Value - 1
print(g_settings.Ammo.Value)
local newaudio = tool.Handle.fireaud:Clone()
newaudio.Parent = tool.Handle
newaudio:Play()
newaudio.Ended:Connect(function() newaudio:Destroy() end)
for i,v in pairs(tool.Handle.fire:GetChildren()) do
if v:IsA("ParticleEmitter") then
v:Emit(30)
end
end
tool.Handle.fire.PointLight.Enabled = true
delay(0.05,function()
tool.Handle.fire.PointLight.Enabled = false
end)
end
end
The “cf” argument is mouse.Hit.Position.
If anyone knows why this is happening, I would greatly appreciate your input.
Thank you,
-Xarciti.