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

Can't debug this error?

Asked by 9 years ago

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

Log in to vote
0
Answered by 9 years ago

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!

0
Still does not work FiredDusk 1466 — 9y
Ad
Log in to vote
0
Answered by 9 years ago

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)

0
That isn't the case, but nice try. I hop you still have a good future. NeonicPlasma 181 — 9y
0
maybe try :MoveTo? instead of .MoveTo? theawesome624 100 — 9y
0
If you're trying to freeze things, try using .Anchored = true theawesome624 100 — 9y
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. NeonicPlasma 181 — 9y

Answer this question