My mob wont move

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

See if this code works:

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
	
	repeat wait() until player.Character
	
	humanoid.Touched:Connect(damage)
	
	while wait() do
		humanoid:MoveTo(player.Character.HumanoidRootPart.Position)
	end
end)

I’ve added a repeat wait() to make sure that the Player’s Character is spawned, and I’ve changed while true to while wait() as to not have the script crash.

I did that cause otherwise I couldnt get the player’s Character

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.