I tried changing Torso to UpperTorso where it was needed, but that didn't seem to work. So how do I change that the Mob will Follow R15 Characters instead of R6?

local Module = require(Game.ServerScriptService.MobFunctions)

local larm = script.Parent:FindFirstChild("Left Arm")
local rarm = script.Parent:FindFirstChild("Right Arm")
local Debounce = false
local OrigPos = script.Parent.Torso.Position

LinkedSword = nil
TicksUntilWander = 0

script.Parent.Name = script.Parent.SETTINGS.MobName.Value .. " [" .. script.Parent.SETTINGS.Lvl.Value.. "]"
script.Parent.Human.Health = script.Parent.Human.MaxHealth

--Damage on hit.
function DamagePlayer(Hit)
	if Hit.Parent:FindFirstChild("Humanoid") ~= nil and script.Parent.Human.Health > 0 then
		if Debounce == false then
			Debounce = true
			Module.AttackPlayer(script.Parent, Hit.Parent:FindFirstChild("Humanoid"), script.Parent.SETTINGS.MinDmg.Value, script.Parent.SETTINGS.MaxDmg.Value, script.Parent.SETTINGS.HitChance.Value, script.Parent.SETTINGS.CritChance.Value, script.Parent.SETTINGS.CritMagnitude.Value)
			wait(script.Parent.SETTINGS.CooldownMagnitude.Value/100)
			Debounce = false
		--else print("Debouncing")
		end
	else 
		return false
	end
end	

function RegisterTool(tool)
	if tool:IsA("Tool") then
		LinkedSword = tool
		LinkedSword.Handle.Touched:connect(DamagePlayer)
	end
end

larm.Touched:connect(DamagePlayer)
rarm.Touched:connect(DamagePlayer)
script.Parent.ChildAdded:connect(RegisterTool)

--XP and Gold on death.
function Died()
local tag = script.Parent.Human:FindFirstChild("creator") 
	if tag ~= nil then 
		if tag.Value ~= nil then 
			local Leaderstats = tag.Value:FindFirstChild("leaderstats") 
			if script.Parent.SETTINGS:FindFirstChild("XP") ~= nil and script.Parent.SETTINGS:FindFirstChild("Gold") ~= nil then
				Module.AddStats(Leaderstats, script.Parent.SETTINGS.XP.Value, script.Parent.SETTINGS.Gold.Value)
			else 
				print("Can't find XP and Gold!")
			end
		end
	end
	if script.Parent:FindFirstChild("Model") ~= nil then
		if script.Parent.Model:FindFirstChild("Part") ~= nil then
			script.Parent.Model:Destroy()
		end
	end
end

script.Parent.Human.Died:connect(Died)

--Spawn initial part for purpose of returning. The purpose of this is to fix the wander as they move in straight line unintentionally.
if script.Parent:FindFirstChild("Model") == nil then
	model = Instance.new("Model", script.Parent)
	part = Instance.new("Part", model)
	part.Anchored = true
	part.CanCollide = false
	part.Transparency = 1
	part.Position = OrigPos	
end

--Follow
function findNearestTorso(pos)
	local list = Game.Workspace:GetChildren()
	local torso = nil
	local dist = script.Parent.SETTINGS.ChaseRange.Value
	local temp = nil
	local human = nil
	local temp2 = nil
	for x = 1, #list do
		temp2 = list[x]
		if (temp2.className == "Model") and (temp2 ~= script.Parent) then
			temp = temp2:FindFirstChild("Torso")
			human = temp2:FindFirstChild("Humanoid")
			if (temp ~= nil) and (human ~= nil) and (human.Health > 0) and (script.Parent.Torso.Position - OrigPos).magnitude <= script.Parent.SETTINGS.ChaseDistance.Value then
				if (temp.Position - pos).magnitude < dist then
					torso = temp
					dist = (temp.Position - pos).magnitude
				end
			end

		end
	end
	return torso
end

while true do
	wait(0.2)
	--Chase
	local target = findNearestTorso(script.Parent.Torso.Position)
	if target ~= nil then
		script.Parent.Human:MoveTo(target.Position, target)
	end
	--Wander
	if TicksUntilWander > 0 then
		TicksUntilWander = TicksUntilWander - 1
	else		
		TicksUntilWander = math.random(10, 25)
		if target == nil then
			if script.Parent:FindFirstChild("Model") ~= nil then
				script.Parent.Human:MoveTo(Vector3.new(OrigPos.X + math.random(-script.Parent.SETTINGS.WanderRadius.Value, script.Parent.SETTINGS.WanderRadius.Value), OrigPos.Y, OrigPos.Z + math.random(-script.Parent.SETTINGS.WanderRadius.Value, script.Parent.SETTINGS.WanderRadius.Value)), script.Parent.Model:FindFirstChild("Part"))
			end
		end
	end
end

2 comments

0

What do you mean by "the Mob will Follow R15 Character instead of R6"? Do you mean the mob only follows players that have R15 avatars and for the ones that have R6, not?

0

When I change the avatartype on my server to "R15" the mobs won't follow my Character. If it's R6 it will follow me, that's my problem.