I have looked at the other asks and saw the solution, however it does NOT work and I get the same error when trying to call localplayer! My localscript is in a gui button btw. view source
local players = game.Players.LocalPlayer
error: attempt to index localplayer(a nil value)
also thanks to scriptguider for pointing something out!

5 comments
Not sure if this is the issue, but you have to wait for your player to be loaded. This included the model, scripts, guis, etc... before that line if you wait for the character to load it might help
the script has a gui button so the character is already loaded.... thx anyway!
local Player = game:GetService("Players").LocalPlayer;
hmm I will try that!
THANK YOU SOOO MUCH I HAVE BEEN SOOO IRRITATED BY THIS!