New: Nitro Boost our Discord server and receive full donation perks here on the website! Join the Scripting Helpers Discord Server to learn more! You can also Support on Patreon as always.
Still have questions? Join our Discord server and get real time help.
0

# attempt to index function with 'Position'?

I have this script that simply moves an NPC to another part, but I get the error "attempt to index function with 'Position'?". Humanoid:MoveTo has always worked for me, so I don't understand why it doesn't work here.

Here's the script:

local move = game.Workspace.interior.WashRoom.move
local kuro = game.Workspace.interior.WashRoom.kuro

wait(3)
print("ah scary")
kuro.Humanoid:MoveTo(move.Position)

0
Basically what the error is saying is that kuro is a function that has been set AFTER the line 2 was set. Hope that helps. RAFA1608 195 — 9d
0
how is that possible? these 6 lines are the only code in the script. flufffybuns 89 — 9d
0
Try setting move.Position to a variable and put the variable in parenthesis. SethHeinzman 268 — 9d
0
okay, ive tried it. The error still persists, but the error is on line 2 (where I put the variable), instead of line 6 flufffybuns 89 — 9d
0
The problem is Humanoid is not a physical body part. Use HumanoidRootPart instead. LoveSpeaksOutTruth 587 — 9d

0
Ziannea 469
9 days ago
Edited 9 days ago

a LOOOOOOONG time ago, models had a function called Model:move(position)

it just teleported the root part (or primarypart) of the model to that position

nowadays, that function is called Model:MoveTo(position), but the old function still exists so that old games don't break

however, when you index an instance, it prioritizes properties, functions, and events over children of that instance

you can confirm this for yourself by running this code in the command bar

local model = Instance.new("Model")
local moveTo = Instance.new("Part")
moveTo.Name = "MoveTo"
moveTo.Parent = model
print(model.MoveTo) --> function: 0x000000000000000


so, for example, if you put a part called "Name" in a model, and tried to get it using Model.Name, it wouldn't give you that part, but the actual name of the model

in your case, when you try to get WashRoom.move, it doesn't give you the part you named move, but rather the function move

really, all you have to do to fix the problem is rename "move" to something else

0
THANK YOU... i changed it, but now there is another problem. For some reason, MoveTo() doesn't work as it should. What happens to me, is that the NPC doesn't actually move towards the part until I get near the NPC. I don't know why this suddenly started happening, I was testing the same script in different places, and the problem happened there too. flufffybuns 89 — 9d
0
I also used an old script I made that had also used the MoveTo() function, and the problem still happens, even though the script had worked before. flufffybuns 89 — 9d
0
weird, is StreamingEnabled turned on Ziannea 469 — 9d
0
nope, hold on ill send a video example of whats going on flufffybuns 89 — 9d