Hello! :) I made a system that when a player press a button on a ScreenGui, the value in leaderstats will change. It works perfectly, the values changes both in the client and in the server. But now I got a problem: I want to change the Local Player's Health to the new value in the leaderstats, so for this I've tried to add this on this simplified version of the Server Script, just for testing if it will work correctly:
game.ReplicatedStorage.RemoteFunction.OnServerInvoke = function(player) print(game.Workspace.player.Humanoid.MaxHealth.Value) end
So when I run it and invoke the server, this appears on the output: player is not a valid member of Workspace
I've also tried change to
game.ReplicatedStorage.RemoteFunction.OnServerInvoke = function(player) print(game.Workspace[player].Humanoid.MaxHealth.Value) end
And
game.ReplicatedStorage.RemoteFunction.OnServerInvoke = function(player) print(game.Workspace:FindFirstChild(player).Humanoid.MaxHealth.Value) end
But they didn't worked too.
Simple solution
You just simply have to reference the name, not the player. You're calling for the player itself, not for the name of it.
game.ReplicatedStorage.RemoteFunction.OnServerInvoke = function(player) print(game.Workspace:FindFirstChild(player.Name).Humanoid.MaxHealth.Value) end