local BlackList = {}
for i,v in pairs(char:GetChildren()) do
if v:IsA("BasePart") then
table.insert(BlackList, v)
end
end
local rayparams = RaycastParams.new()
rayparams.FilterDescendantsInstances = {BlackList}
rayparams.FilterType = Enum.RaycastFilterType.Blacklist
for i,v in pairs(game.Players:GetPlayers()) do
local direction = v.Character.HumanoidRootPart.Position - char.HumanoidRootPart.Position
local NewRayResult = workspace:Raycast(char.HumanoidRootPart.Position, direction,rayparams)
print(v.Character.Name)
if NewRayResult.Instance then
if NewRayResult.Instance:FindFirstChildOfClass("Humanoid") then
if NewRayResult.Distance < 6 then
NewRayResult.Instance:FindFirstChild("Humanoid"):TakeDamage(damage.Value)
task.spawn(function()
NewRayResult.Instance:FindFirstChild("Humanoid").WalkSpeed = 6
task.wait(0.6)
NewRayResult.Instance:FindFirstChild("Humanoid").WalkSpeed = 16
end)
return v
end
end
else
warn("Cannot find raycast direction")
end
end
this is my code i am getting the other players character by looping through the players but it returns the āattempt to index nil with instanceā error does anybody know why?