attempt to index upvalue 'player' (a nil value)?
Asked by
8 years ago Edited 8 years ago
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).
1 | while (player.Character.Humanoid.WalkSpeed < 40 ) do |
2 | player.Character.Humanoid.WalkSpeed = player.Character.Humanoid.WalkSpeed + 4 |
4 | runSpeed = runSpeed + 0.7 |
5 | trackAnimation:AdjustSpeed(runSpeed) |
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.
2 | local Players = game:GetService( "Players" ) |
3 | local UIS = game:GetService( "UserInputService" ) |
6 | local player = Players.LocalPlayer |