I made this script,
it is called a handler, a script and it is inside of ServerScriptService
local Events = game:GetService("ReplicatedStorage").Events
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local function getStat(plr, nameValue)
return ReplicatedStorage.Stats:FindFirstChild(plr):FindFirstChild(nameValue).Value
end
Events.GetStat.OnServerInvoke = getStat()
But when I test it, it gave me an error saying, " Argument 1 missing or nil"
Here are the script that is related to it this script is called a display, and it is a "local script" inside of a "frame"
local Events = game:GetService("ReplicatedStorage").Events
while wait(0.1) do
local gvalue = Events.GetStat:InvokeServer("Grass")
local limit = Events.GetStat:InvokeServer("Limit")
script.Parent.LimitText.Text = tostring(gvalue).."/".. tostring(limit)
end
Can anyone help? Thanks!

5 comments
What happens when you remove the parenthesis from the "getStat" assignement so that it becomes "Events.GetStat.OnServerInvoke = getStat"
Note: I think there is a limit to how often you can invoke the server. Or if there isn't it will cause a lot of lag.
You would have to do plr.Name for :FindFirstChld to work
plr is an object
Don't use wait(0.1) as a condition. It's a hack.