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

attempt to call a nil value?

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

✓ Accepted answer

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

  1. it's defined before it's called
  2. it returns a value

4 comments

0

How do I know if it returns a value

0

if your function includes a return line then it will return whatever data is to the right of the return

0

ohh ok

0

if this solved your problem could you please mark it as the answer?

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

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