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

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

Asked by 7 years ago
Edited 7 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).

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
0
How are you getting the player? User#5423 17 — 7y
0
GetService JohnnyS_Sinns 27 — 7y
0
Players is a service. A player is an object. GoldenPhysics 474 — 7y
0
I edited my question, please check it out. JohnnyS_Sinns 27 — 7y

2 answers

Log in to vote
0
Answered by 7 years ago

I think trackAnimation is undiefined

0
I though that too, but if remove that (trackAnimation:AdjustSpeed(runSpeed)) and the error stills there. JohnnyS_Sinns 27 — 7y
0
Okay. iiNebulaKing -2 — 7y
Ad
Log in to vote
0
Answered by 7 years ago

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.

Answer this question