So I'm trying to make a script that adds a point to the leaderstats on the leaderboard with a ClickDetector. The problem is that it does not find the leaderstats in the LocalPlayer for some reason (as seen in the error I got:'leaderstats is not a valid member of Player'). How can I fix this so it adds a point to the leaderboard when you pick up the object? Thanks for the help!
(NOTE: This is a LocalScript that is ran under a ClickDetector inside a Union)
Here is the script:
local MeatValue = game.Players.LocalPlayer.leaderstats.Meat.Value function GiveMeat() MeatValue = MeatValue + 1 script.Parent.Parent:Remove() end script.Parent.MouseClick:connect(GiveMeat)
All of the information that is here from others is incorrect if you look at the ClickDetector Wiki if you scroll down to the events and look at MouseClick,you will see that it says that it returns the player who clicked it.
All you would need to change in your code:
function GiveMeat(player) local MeatValue = player.leaderstats.Meat.Value; MeatValue = MeatValue + 1; script.Parent.Parent:Destroy(); -- Remove is deprecated end; script.Parent.MouseClick:connect(GiveMeat);
** This should also be in a regular script **
I hope this helps! If it does please accept this as the answer. If it didn't help feel free to ask for more help with it, or if you have any other questions just ask.