Character only moving if it has killed already an player (AI)

Hello Devforum Member

Dont judge me on my name please.

I tried creating an Character Movement that moves to you when you are being targeted. The thing is it works pretty normal on a Baseplate. Once I put it into the SCPF Area it still work fine in testings once you go into the Roblox Application it won’t move and will only move if it killed already an player. I tried already some solutions by checking if the Character is fully loaded. Or by increasing the range a bit. The whole movement system goes over an Module to handle that.

The module script:

local AIService = {}

function AIService.CreateSCPAI(SCPModel)
	local SCPService = {}
	local SCPRoot = SCPModel:FindFirstChild('HumanoidRootPart') or SCPModel.Torso
	local SCPHumanoid = SCPModel.Humanoid
	function SCPService:FetchTarget()
		local SearchDistance = 200
		local Target = nil
		for i,v in pairs (game.Players:GetChildren()) do
			if v.Character then
				local Root = v.Character:FindFirstChild('HumanoidRootPart')
				print(Root.Position)
				if Root then
					if (SCPRoot.Position - Root.Position).magnitude < SearchDistance and v.Character.Humanoid.Health > 0 then
						warn('fv')
						SearchDistance = (SCPRoot.Position - Root.Position).magnitude
						Target = Root
					end
				end
			end
		end
		return Target
	end
	function SCPService:MoveCharacter(Target)
		if Target then
			SCPHumanoid:MoveTo(Target.Position)
		end
	end
	return SCPService
end

return AIService

This is the script I use to require the Module for the SCP(Character)

local AIService = require(game.ServerScriptService.Services.AIService)
local AI = AIService.CreateSCPAI(script.Parent)

while wait(.1) do
	local target = AI:FetchTarget()
	AI:MoveCharacter(target)
end

Thank you for any ideas how I could solve that.

Do you receive any errors while you are in the Roblox application or not?

I don’t receive any error. Already checked that multiple times.

The chances of this being the solution are low but it is very important you correct this practice:

Utilize

game:GetService("service");

over

game.service

EDIT: Also, try using FindFirstChild() instead of dot syntax.