--Format
ServerScript
PlayerStats(Folder)
Bob(Folder)
Stats(Folder)
Coins(numValue)
-- Server script
function MakeSureCoinsAreNotHacked.OnServerInvoke(PlayerName) local PlayerFile = script.PlayerStats:FindFirstChild(PlayerName) local PlayerCoins = PlayerFile.Stats.Coins return PlayerCoins.Value
--Local script
local MakeSureCoinsAreNotHacked = MakeSureCoinsAreNotHacked:InvokeServer(game.Players.LocalPlayer.Name)
output - 18:37:53.935 - ServerScriptService.PlayerStatsHandler:40: attempt to index local 'PlayerFile' (a nil value)
Ok so the first argument on an OnServerInvoke function is always the player who called InvokeServer(). You can then get the name of the player from the first argument rather than passing the player's name along with the player. Also since you used :FindFirstChild() on a userdata value instead of a string, it returned a nil value.
function MakeSureCoinsAreNotHacked.OnServerInvoke(Player) -- Player is always the first argument local PlayerName = Player.Name -- Get the player's name local PlayerFile = script.PlayerStats:FindFirstChild(PlayerName) local PlayerCoins = PlayerFile.Stats.Coins return PlayerCoins.Value local MakeSureCoinsAreNotHacked = MakeSureCoinsAreNotHacked:InvokeServer()