|
| 20 Jul 2015 04:37 PM |
Hiyo! I'm having a problem with a local script that I can't seem to explain. The third line of the script is as follows:
local Humanoid = game.Players.LocalPlayer.Character.Humanoid
I need to access the player's character model to adjust their walk speed. This line is copied and pasted from the ROBLOX wiki, but I get the following error message in game mode:
Players.Player1.PlayerGui.LocalScript:3: attempt to index field 'Character' (a nil value)
I have no idea what's going on, I've used this exact line of code before and it's worked fine. Does anyone have any idea what the deal might be? |
|
|
| Report Abuse |
|
|
|
| 20 Jul 2015 04:39 PM |
local Player = game.Players.LocalPlayer local Character = Player.Character or Player.CharacterAdded:wait()
local Humanoid = Character.Humanoid |
|
|
| Report Abuse |
|
|
|
| 20 Jul 2015 04:41 PM |
| I forgot to mention, I originally had the script in startergui. I tried putting it in starterpack as well, neither worked. |
|
|
| Report Abuse |
|
|
|
| 20 Jul 2015 04:44 PM |
That means nothing, unless it's not a LocalScript. If you want persistent scripts, you should place them in PlayerScripts. |
|
|
| Report Abuse |
|
|
|
| 20 Jul 2015 04:46 PM |
The local script in question performs a function when the "f" key is pressed.
To use keydown, don't you put a local script in the player's starterpack or startergui? |
|
|
| Report Abuse |
|
|
|
| 20 Jul 2015 04:48 PM |
| Yes, does my code not work. |
|
|
| Report Abuse |
|
|
|
| 20 Jul 2015 04:49 PM |
| I tried making the change, it also didn't work. I suppose I can try starting again from scratch, but this makes no sense. |
|
|
| Report Abuse |
|
|