Remote function not recieving parameter

I am trying to deliver the mouse position to the server from a local script using a remote function as seen below. However the script prints nil and does not work. This is my first time using a remote function so I really don’t know what else to try. player is defined properly in the server script.

Server script:

	local mouseHit = game.ReplicatedStorage.getMouseLocation:InvokeClient(player)

Local script:

	game.ReplicatedStorage.getMouseLocation.OnClientInvoke = function(player)
	print(player)
	return player:GetMouse().Target
end

The LocalScript shouldn’t be recieving the Player argument.

local Players = game:GetService("Players")
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local LocalPlayer = Players.LocalPlayer
ReplicatedStorage:WaitForChild("getMouseLocation").OnClientInvoke = function()
	return LocalPlayer:GetMouse().Target
end

I don’t have time to test it out right now, but this should work.

2 Likes

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.