I'm having a little trouble using RemoteFunction. I am trying to have a LocalScript in StarterGUI return something to a Script in a Part in Workspace. This is an excerpt from the Script:
local gcm = game.ReplicatedStorage:WaitForChild("getClientMouse")
local mouse = gcm:InvokeClient(playerName, nil)
It keeps giving me an error with the second line, saying 'unable to cast value to Object' I'm not sure why this is In case you need my LocalScript code
remotefunction = game.ReplicatedStorage:WaitForChild("getClientMouse")
function remotefunction.OnClientInvoke(playerName)
print(game.Players.LocalPlayer:GetMouse().ClassName)
return game.Players.LocalPlayer:GetMouse()
end

6 comments
Are you sure you're invoking the client with the actual Player object? or you're invoking with the name as the variable seems to represent
also why did you write nil in the 2nd argument
Because it says in the API that the 2nd argument is a required Tuple so since I didn't have one I just put nil
can the server even access the player mouse?
Nope, you need to use a LocalScript in StarterGui because Player:GetMouse() only works in LocalScripts
when you're not going to need the Tuple just don't write the 2nd argument as it is the same as if you wrote nil