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)

7 comments
Don't use a LocalScript; Use a regular Script. The player who clicked will be automatically passed as first argument to your 'GiveMeat' function by Roblox.
I don't think you can detect a player through clickdetector. Correct me if I'm wrong.
Meltdown, then you are completely wrong. MouseClick returns the player who clicked it.
Hmm, I was absolutely certain that ClickDetector MouseClick did not return anything. Did Roblox change it recently?
First of all, it's an argument, not a return value. Secondly, it always has.
No, MouseClick is an event which returns player. Not a function.
@Link150 had the answer. All i had to do was change it to a localscript and it worked. Thanks for answering anyways guys!