hello. just trying to test out my anticheat's detection with this script to shoot the arrow at a player's head.. but it keeps on giving me this error.
Players.c_hubs.PlayerScripts.Bullet Unable to cast Instance to Bool Line 1 function au
Any help?
local localPlayer = game:GetService("Players").LocalPlayer
function getClosestPlayer()
local closestPlayer = nil
local shortestDistance = math.huge
for i, v in pairs(game:GetService("Players"):GetPlayers()) do
if v ~= localPlayer and v.Character and v.Character:FindFirstChild("Humanoid") and v.Character.Humanoid.Health ~= 0 and v.Character:FindFirstChild("HumanoidRootPart") and v.Character:FindFirstChild("Head") then
local magnitude = (v.Character.HumanoidRootPart.Position - localPlayer.Character.HumanoidRootPart.Position).magnitude
if magnitude < shortestDistance then
closestPlayer = v
shortestDistance = magnitude
end
end
end
return closestPlayer or localPlayer
end
local mt = getrawmetatable(game)
local oldNamecall = mt.__namecall
if setreadonly then setreadonly(mt, false) else make_writeable(mt, true) end
local namecallMethod = getnamecallmethod or get_namecall_method
local newClose = newcclosure or function(f) return f end
mt.__namecall = newClose(function(...)
local method = namecallMethod()
local args = {...}
if tostring(method) == "FireServer" and tostring(args[1]) == "Projectile" then
args[2] = getClosestPlayer().Character.Head.Position
args[2] = Bow
args[2] = getClosestPlayer().Character.Head.Position
return oldNamecall(unpack(args))
end
return oldNamecall(...)
end)
if setreadonly then setreadonly(mt, true) else make_writeable(mt, false) end
