RayHit doesnt seem to be firing for me
local module = {}
local RS = game:GetService("ReplicatedStorage")
local Modules = RS:WaitForChild("Modules")
local FastCast = require(Modules:WaitForChild("FastCastRedux"))
local OnHit = require(script:WaitForChild("OnHit"))
local Caster = FastCast.new()
local Behaviour = FastCast.newBehavior()
local cBullet = Instance.new("Part")
cBullet.Size = Vector3.new(0.1,0.1,0.2)
cBullet.Anchored = true
cBullet.CanCollide = false
cBullet.Color = Color3.fromRGB(18, 18, 18)
local CastParams = RaycastParams.new()
CastParams.IgnoreWater = true
CastParams.FilterType = Enum.RaycastFilterType.Blacklist
Behaviour.CosmeticBulletTemplate = cBullet
Behaviour.CosmeticBulletContainer = workspace
Behaviour.RaycastParams = CastParams
Behaviour.Acceleration = Vector3.new(0,-9.8,0)
Caster.LengthChanged:Connect(function(CasterThatFired, LastPos, RayDir, Displacement, SegmentVelocity, Bullet)
Bullet.Position = LastPos + (RayDir * Displacement)
end)
Caster.RayHit:Connect(function(CasterThatFired, RayResult, SegmentVelocity, Bullet)
local Hit = RayResult.Instance
print("Hit")
if Hit.Parent:FindFirstChild("Humanoid") then
print("Hum")
local Func = OnHit[Hit.Name]
if Func then
print("Func")
Func(Hit, RayResult)
end
end
end)
Caster.CastTerminating:Connect(function(ActiveCast)
ActiveCast.RayInfo.CosmeticBulletObject:Destroy()
end)
function module.OnFire(Tool)
local Pistol = Tool.Pistol
Pistol.Pistol.Fired:Play()
CastParams.FilterDescendantsInstances = {Tool}
local Origin = Pistol.Tip.Position
local Direction = -Pistol.Bolt.CFrame.LookVector
Caster:Fire(
Origin,
Direction,
150,
Behaviour
)
end
return module
doesnt print or error anything even if i shoot directly at a wall. The bullet is fired, its even visible. And it goes straight trough anything i shoot it at without firing the rayhit. Ive been trying to solve this for days now.
This is on the server in a module by the way.