Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

the function mob.Move(mob, workspace) code is not working, anyone know why?

So I am trying to make the "Mob" aka ambush move, I don't remember how I did it before with another game so instead I copied the code:

script.Parent.MouseButton1Click:Connect(function()
	local mob = workspace.Ambush

	function mob.Move(mob, workspace)
		local humanoid = mob:WaitForChild("Humanoid")
		local waypoints = workspace.Waypoints

		for waypoint=1, #waypoints:GetChildren() do
			humanoid:MoveTo(waypoints[waypoint].Position)
			humanoid.MoveToFinished:Wait()
		end
	end
end)

It isn't working. Anyone know why and how to help pls?

8 comments

0

Cant confirm, so not putting it as a answer. I believe it may be because mob.Move needs mob to be a table, however it does not look like it is one. Is ambush something like a folder or is it a module script? If its a module script you need to call require() around it.

0

it's a model

0

Add prints around it, I think that might be why then.

1

You're using the function like you're trying to call it as if it were stored inside of a table. Since "mob" is an object, it's trying to find a member inside of the object that has the name "Move"; which explains the error you're receiving. To solve this particular error, you can either remove the "mob." next to the function name or remove the function itself as it seems unnecessary here.

0

You may be confused with pathfinding? From what I can gather, it looks like you're trying to pathfind the NPC but may be confused on how it works or have forgotten. If I'm correct, it might be worth your time looking at the documentation for pathfinding. https://create.roblox.com/docs/mechanics/pathfinding

0

Nothing is working?

0

The first comment might work i Just don't know where you want me to call require

1 answer

local mob = workspace.Ambush
function mob.Move(mob, workspace)

The function will not work as the mob, which is A Model, cannot have custom functions set to it. Someone already answered your question (credit to xInfinityBear). You should create a module for your functions, or name the function something else and call it

This discussion is preserved as it was. New answers, comments, and votes are closed.