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

Can't debug this error?

I have this script that will help me test if I can freeze players in objects. But it doesn't work because of the error:

game.Players.PlayerAdded:connect(function(player)
	player.CharacterAdded:connect(function(char)
		local MoveTo = game.Workspace.MoveTo
		char:MoveTo(MoveTo.Position)
	end)
end)

In my output, I get:

15:46:19.201 - Workspace.Script:4: attempt to index local 'MoveTo' (a function value)

15:46:19.202 - Stack Begin

15:46:19.203 - Script 'Workspace.Script', Line 4.

15:46:19.203 - Stack End

I have not experienced these kind of errors. Could anyone help me debug this script? Thanks!

2 answers

✓ Accepted answer

hi names are not unique

First, let's tackle the error.

What does it mean by 'indexing a function value'?

As you know, :MoveTo is a function, for both humanoids and models.

What :MoveTo does is it moves models to the desired position, but if used in a humanoid, the humanoid walks to the position instead of just teleporting into it.

Now, that has nothing to do about the error, except for the MoveTo is a function part.

So, MoveTo is a function, what now?

The script thinks you're referencing the function, instead of the instance!

There are indexing priorities, which are very important in scripting, and methods are prioritzed more than instances, so it found MoveTo as a function first.

So an easy way to fix this error is by renaming the part instead!

1 comment

0

Still does not work

I am not an expert, but

game.Workspace.MoveTo

? It appears that it thinks MoveTo is a part name(again I'm not an expert, but I'm just trying to help)

4 comments

0

That isn't the case, but nice try. I hop you still have a good future.

0

maybe try :MoveTo? instead of .MoveTo?

0

If you're trying to freeze things, try using .Anchored = true

0

Yeah, well, I'm trying to freeze a PLAYER, so if I anchor it, they won't move, but the Humanoid can still move. That's the problem.

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