Client Code:
local FireDebounce = false
Tool.Activated:Connect(function()
if FireDebounce == false then
if (CurrentArms:FindFirstChild("Sheriff"):WaitForChild("Barrel").Position - Mouse.Hit.Position).magnitude < 999 then
local Raycastparams = RaycastParams.new()
Raycastparams.FilterType = Enum.RaycastFilterType.Blacklist
Raycastparams.FilterDescendantsInstances = {Player.Character,workspace.Rays}
local Result = workspace:Raycast(CurrentArms:FindFirstChild("Sheriff"):WaitForChild("Barrel").CFrame.p,Mouse.Hit.p-CurrentArms:FindFirstChild("Sheriff"):WaitForChild("Barrel").CFrame.p,Raycastparams)
print(Result)
if Result ~= nil then
RemoveAnims()
FireDebounce = true
if CurrentArms ~= nil then
CurrentArms:FindFirstChild("Sheriff").Barrel.MuzzleEffect.Enabled = true
end
if Result.Instance ~= nil then
if Result.Instance.Parent:FindFirstChild("Zombie") then
SituationEvent:FireServer("Clicked",Result.Distance,CurrentArms.Sheriff.Barrel.Position,Mouse.Hit.Position,Result.Instance.Parent,"NPC",Result.Instance)
elseif Result.Instance.Parent:FindFirstChild("Humanoid") then
SituationEvent:FireServer("Clicked",Result.Distance,CurrentArms.Sheriff.Barrel.Position,Mouse.Hit.Position,Result.Instance.Parent,"Player",Result.Instance)
else
SituationEvent:FireServer("Clicked",Result.Distance,CurrentArms.Sheriff.Barrel.Position,Mouse.Hit.Position,nil,nil)
end
end
_G.Camera("Offset")
wait(.45)
if CurrentArms ~= nil then
CurrentArms:FindFirstChild("Sheriff").Barrel.MuzzleEffect.Enabled = false
end
FireDebounce = false
end
end
end
end)
Sometimes print nil, sometimes working perfectly
Problem line:
local Result = workspace:Raycast(CurrentArms:FindFirstChild("Sheriff"):WaitForChild("Barrel").CFrame.p,Mouse.Hit.p-CurrentArms:FindFirstChild("Sheriff"):WaitForChild("Barrel").CFrame.p,Raycastparams)