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

attempt to call a nil value?

Asked by 2 years ago

I am making a horizontal tower of hell like bar but when I test it an error pops up saying "attempt to call a nil value". This is the code where the error occurs:

function Update()

    for index, Player in next, PlayerLengthData do
        local xPosition = Player:GetLengthFromEnd()

        Player.Frame.Position = UDim2.new(xPosition, 0, 0.5, 0)
    end

end

The error is on line 4. I don't know how to fix this error so please help.

2 answers

Log in to vote
0
Answered by 2 years ago

Player:GetLengthFromEnd() might not be a valid function, make sure that

  1. it's defined before it's called
  2. it returns a value
0
How do I know if it returns a value aydenwilson819 25 — 2y
0
if your function includes a `return` line then it will return whatever data is to the right of the `return` TheDude646 72 — 2y
0
ohh ok aydenwilson819 25 — 2y
0
if this solved your problem could you please mark it as the answer? TheDude646 72 — 2y
Ad
Log in to vote
0
Answered by 2 years ago

As the error says, you are attempting to call a nil value, which would be GetLengthFromEnd.

Answer this question