local player = game:GetService("Players").LocalPlayer
This is the script i use for player variables, somehow when i test with emulator it says its a nil value, althrough i tried with wait(0.1), and repeat wait() until player ~= nil, but it keeps doing that.

4 comments
use an if statement before defining the variable
what do you mean?
"if game.Players.LocalPlayer ~= nil then"
then define the variable