Im making an fps game but my bot has perfect aim any way to fix that?
local DISTANCE = 70
local Players = game:GetService("Players")
local origin = script.Parent.Head
local equip = script.Parent:WaitForChild("Humanoid").Animator:LoadAnimation(script.Parent.Anims.Equip)
local idle = script.Parent:WaitForChild("Humanoid").Animator:LoadAnimation(script.Parent.Anims.Idle)
local fire = script.Parent:WaitForChild("Humanoid").Animator:LoadAnimation(script.Parent.Anims.Fire)
local walk = script.Parent:WaitForChild("Humanoid").Animator:LoadAnimation(script.Parent.Anims.Walk)
db = false
while task.wait() do
for _, player in pairs(Players:GetPlayers()) do
if player.Character then
local HumanoidRootPart = player.Character:FindFirstChild("HumanoidRootPart")
local rayParams = RaycastParams.new()
rayParams.FilterDescendantsInstances = {player.Character, workspace.Map}
rayParams.FilterType = Enum.RaycastFilterType.Whitelist
local result = workspace:Raycast(origin.Position, CFrame.lookAt(origin.Position, HumanoidRootPart.Position).LookVector * DISTANCE, rayParams)
if result and result.Instance:IsDescendantOf(player.Character) then
local name = player.Name
script.Parent.Head.face.Transparency = 0
idle:Play()
equip:Play()
local ObjectPosition = game.Workspace:WaitForChild(name).PrimaryPart.Position
script.Parent.PrimaryPart.CFrame = CFrame.new(script.Parent.PrimaryPart.Position, Vector3.new(ObjectPosition.x, script.Parent.PrimaryPart.Position.y, ObjectPosition.z))
if db == false then
db = true
fire:Play()
game.Workspace:WaitForChild(name):WaitForChild("Humanoid").Health -= 24
script.Shoot:Play()
script.Parent.Humanoid:MoveTo(game.Workspace:WaitForChild(name).PrimaryPart.Position)
walk:Play()
script.Parent.Humanoid.MoveToFinished:Connect(function()
walk:Stop()
idle:Stop()
end)
script.Parent.Head.face.Transparency = 1
wait(2)
db = false
end
end
end
end
end