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

attempt to index upvalue 'player' (a nil value)?

Hi again community,

Well, this time I have an script that when you press LShift the player starts to increase his max speed (if he's actual speed is less than 40) and the same for his animation (they're in the same loop).

while(player.Character.Humanoid.WalkSpeed < 40)do
	player.Character.Humanoid.WalkSpeed = player.Character.Humanoid.WalkSpeed + 4
			
	runSpeed = runSpeed + 0.7
	trackAnimation:AdjustSpeed(runSpeed)		

	wait(0.5)
end

The script works just fine, the problem appears when I run the game and press LShift this shows up on my output:

44: attempt to index upvalue 'player' (a nil value)

When I release the LShift Key shows up again.

I was ignoring it for now, but sometimes it just destroy the game because the speed and my animation get stucked and now I have a game with an animation in a loop and his max speed even if you're not even moving.

What am I missing here?

I really appreciate any help you can provide.

EDIT:

  1. I don't know if the error comes from another line of code and its popping up there.
  2. This is the way I get the player.
--// Services
local Players = game:GetService("Players")
local UIS = game:GetService("UserInputService")

--// Local Variables
local player = Players.LocalPlayer

4 comments

0

How are you getting the player?

0

GetService

0

Players is a service. A player is an object.

0

I edited my question, please check it out.

2 answers

I think trackAnimation is undiefined

2 comments

0

I though that too, but if remove that (trackAnimation:AdjustSpeed(runSpeed)) and the error stills there.

0

Okay.

Problem fixed.

I wasn't updating the plugin on-line. So the version I had on my Studio was crashing against the local one.

I've still have the animation and speed problem but I think that is more logical than something else.

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