I am making a button that when you click on it, it subtracts the cost from your points and opens the egg so you get a pet, like in simulator games. My issue is that I am struggling to grab the players point value. Points are NOT displayed on the leaderstats, they are stored in the Player.
This is not a local script
script.Parent.MouseButton1Down:Connect(function() local plr = game.Players.LocalPlayer if plr.Points.Value >= cost then plr.Points.Value = plr.Points.Value - cost local pet = petModule.chooseRandomPet() print(pet.Name.." selected") end end)
You cannot get LocalPlayer in a server script. To find it, replace line 3 with this:
local plr = script.Parent --Continue adding parents until plr is equal to the player
Example: script > button > frame > screengui
local plr = script.Parent.Parent.Parent.Parent.Parent --All guis go in playerGui, which is in the player
I hope this answers your question