1

# attempt to call a nil value?

Asked by 5 days 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.

0
Answered by 5 days 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 21 — 5d
0
if your function includes a return line then it will return whatever data is to the right of the return TheDude646 72 — 5d
0
ohh ok aydenwilson819 21 — 4d
0
if this solved your problem could you please mark it as the answer? TheDude646 72 — 4d
As the error says, you are attempting to call a nil value, which would be GetLengthFromEnd.