My mob wont move

I made a mob that’s supposed to move towards the player. However, it couldn’t move despite doing the same method all the time. I’m not sure if Roblox changed things or I’m doing something wrong. I have rewritten my code 5 times, yet the mob doesn’t move. It stands still. Yes, I have it unanchored.

Here’s the code:
Script is inside the mob

game.Players.PlayerAdded:Connect(function(player)
	local humanoid = script.Parent.Humanoid
	
	
	local function damage(hit)
		if hit.Parent:FindFirstChild("Humanoid") then
			hit.Parent.Humanoid.Health -=3
		end
	end


	while true do
		humanoid:Move(player.Character.HumanoidRootPart.Position)
		humanoid.Touched:Connect(damage())
	end
end)

I couldn’t find the solution to my issue.

1 Like

oof, try to use MoveTo(vector3) maybe. i got the same problem when using Move(vector3) so i don’t use it anymore

I tried :Move() instead of :MoveTo() yet same results

oh maybe try to move while loop outside the PlayerAdded function?. and humanoid.Touched:Connect(damage()) you don’t need to loop this. it will automatically fired when something touching.

Note: humanoid.Touched:Connect(damage()) humanoid can’t be touched, maybe try use “humaoidrootpart”

It says “attempting to index nil with PrimaryPart”. What am I doing wrong?

oh… that explains why… set the mob primary part to

HumanoidRootPart (R15)
Torso (R6)

and you’re good to go

Same result. I get the same error. Keep in mind I used this method before and it was working

maybe try to replace current mob?

I’m gonna test this in a new place

Ok it doesnt work. What do you suggest I should do?

@ImaAetherangel

1 Like

Hello!
Is this the issue?

try to use this. maybe you got an error because the player humanoid isn’t ready yet

from this:
humanoid:Move(player.Character.HumanoidRootPart.Position)

to this:
local char = player.Character or player.CharacterAdded:Wait() humanoid:Move(char:WaitForChild (HumanoidRootPart).Position)

@cravedbloxy

That has nothing to do with my issue

Sorry about thatㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤ

if your mob is going to be moving towards the player, then you’re referencing nothing? you seem to be just referencing the player that joins in every time. just set the script as a parent to your mob instead of serverscriptservice.

The script is inside the mob not in ServerScriptService. I edited the post.

The script kinda works now. Except it’s not following the player.

i don’t think it’s going to work if the function will activate with a player joining, i highly recommend you just make a loop, and get the closest player to you by using .Magnitude and then the closest player will make the mob follow them maybe?

i would also maybe try

humanoid:MoveTo(player.PrimaryPart.Position)

hah! use MoveTo() instead!. i guarantee it works

It’s still facing the wall lol