So there Is a problem, I am making a bossfight game and there would be a spawner that spawns beanos however the problem Is that beanos pathfinding script will work fine when not being cloned by replicated storage but will not work when being cloned by replicated storage, this all has to do by the moving script Itself
script:
local function FindTarget()
local maxDistance = 100000
local target = nil
for i,v in pairs(workspace:GetChildren()) do
if v:FindFirstChild("Humanoid") then
if (v.Head.Position-script.Parent.Head.Position).magnitude < maxDistance then
target = v.Head
end
end
end
return target
end
while wait() do
local target = FindTarget()
if target then
script.Parent.Humanoid:MoveTo(target.Position)
end
end
