I am making a game called Crop Farm Tycoon and when you click the soil it gives you seeds. Now when you click the seed it is suppose to grow the crop. Please Note that this script works in studio mode, but not in Player Mode.
I have been reading articles saying that LocalPlayer does not always work in scripts. How do I fix this?
I use the script line,
game.Players.LocalPlayer
..but that only works in Studio Mode and when I test it in Player Mode it is like I never even done the script!
{ All I want to know is what to use instead of LocalPlayer to make this work work please give me a main thing that means localplayer, but isn't actually localplayer with an explanation please!}
You're most likely trying to index
LocalPlayer
from a Server Script.LocalPlayer
can only be indexed in aLocalScript
.
LocalScript
can only access the LocalPlayer.
A solution could be to put a local script into one of the StarterServices, preferably StarterCharacterScripts
.
NOTE: Make sure to use UserInputService instead of mouse for keyboard button pushing.
But if you mean to click a part that isn't a GUI button, you can use the instance ClickDetector and use .MouseClick
connection for that instance into your script.