Hi, my script under here make a output: "attempt to index upvalue 'LocalPlayer' (a nil value)"
local PlayerService = game:GetService("Players") local LocalPlayer = PlayerService.LocalPlayer
Thank you for reading, if you know how to help me. Feel free to tell me. -Toby
The solution to your problem is very simple: Servers and Clients. Server scripts are meant to control aspects of the game for every player to see. Local scripts do the opposite. LocalScripts control content for the specific player to see. Some functions and objects are only allowed to be accessed by local scripts. The keyword 'LocalPlayer' can only be acessed in a local script, not a server script.
Scripts runs "server sided" (which basically means on the roblox server), which allows scripts to be ran for all players. Local scripts run "on your computer/ for the current player". This uses Client-Sided events and properties such as getting the player with game.Players.LocalPlayer or getting the camera/mouse.
When trying to access LocalPlayer from a normal script (server script), it returns an error letting you know that 'LocalPlayer' is nil, because it has an undefined value. Error: "attempt to index upvalue 'LocalPlayer' (a nil value)"
The solution is instead of placing this code inside a script, you insert it inside a Local script.
Look at the "PromptPassPurchase" script to identify what a local script looks like
One more thing, since LocalScripts run on the client you are not allowed to place them in server areas. For now, just remember to put them in "Player" areas so that they run to the client. Place your script inside StarterPlayer, StarterGui,PlayerScripts,etc.
Here is the solution to your problem. If this helps, please check awnser and I would see you later!