I am currently learning how RemoteEvents, and RemoteFunctions work, and in my game, I want to send an IntValue from the server to a specific client, and update that player's MoneyGui to show the sent IntValue. However, I keep getting an error in the output saying, "attempt to call a number value". Does anyone know why?
Also, I understand the difference between RemoteFunctions and RemoteEvents. RemoteFunctions can send and receive information two ways, while RemoteEvents can only send and receive information one way. I would use a RemoteEvent, except I don't know how to access a value sent from a RemoteEvent.
Here is the code.
Server Script
script.Parent.Touched:Connect(function(hit)
local sendValue = game.ReplicatedStorage.SendValue
local player = game.Players:GetPlayerFromCharacter(hit.Parent)
local storedValue = script.Parent.Parent.storedValue
local function returnValue()
return storedValue.Value
end
if player then
sendValue.OnServerInvoke = returnValue()
end
end)
Client Script (Inside of a textLabel)
while wait() do
local getValue = game:GetService("ReplicatedStorage"):FindFirstChild("SendValue"):InvokeServer()
script.Parent.Text = tostring(getValue)
end
I hope this made sense.
Thanks in advance!

5 comments
It works! Thanks man. I have been trying to figure this out all day.
Just curious, if I used a RemoteEvent, and Fired to the Client an IntVale, how would I access the value I fired, from the local script? I am still learning how Events work, and I think it would be easier to simply Fire the Value to the client each time the part is touched. Thanks again.
add a parameter called plr, and in that send the players name, then in the server script fire to the client with the player you sent, its a bit of a hacky way
You don't need to make returnValue an anonymous function, it could stay named as he wanted it. It's just a matter of assigning the function reference, not calling it. i.e.
sendValue.OnServerInvoke = returnValue()should have beensendValue.OnServerInvoke = returnValue...but, I think there are bigger problems with this code, in terms of how it's meant to work for multiple players. Assigning a remoteFunction's OnServerInvoke more than once is unusual, and almost certainly not what you want here.