Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
1

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

Asked by
VipDanT 10
1 year ago

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?

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. Jay123abc2 241 — 1y
0
it's a model VipDanT 10 — 1y
0
Add prints around it, I think that might be why then. Jay123abc2 241 — 1y
View all comments (4 more)
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. xInfinityBear 1777 — 1y
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 xInfinityBear 1777 — 1y
0
Nothing is working? VipDanT 10 — 1y
0
The first comment might work i Just don't know where you want me to call require VipDanT 10 — 1y

1 answer

Log in to vote
0
Answered by 1 year ago
Edited 1 year ago
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

Ad

Answer this question