Remote arguments help needed!

I want to print the position of the mouse

I’m new to remotes and arguments and I am stuck!

I have looked around the developer hub but It doesn’t solve my issue.

LOCAL SCRIPT:

local player = game.Players.LocalPlayer
local parts = workspace.Union
local RS = game.ReplicatedStorage
local mouse = player:GetMouse()
mouse.Button1Down:Connect(function()
	local loc = mouse.Hit.Position
	RS.Pos:FireServer(loc)

	
end)

SERVER SCRIPT:

local RS = game.ReplicatedStorage
local function pos(loc)
print(loc)
	
	
end
RS.Pos.OnServerEvent:Connect(pos)

I had this issue aswell, Studio thinks that you have loc as a player value, so change it to this RS.Pos:FireServer(plr, loc)

local RS = game.ReplicatedStorage
local function pos(player,loc)
print(loc)
	
	
end
RS.Pos.OnServerEvent:Connect(pos)

you always need to provide the player as first argument on server side call.

When firing to the server, the server always receives the player as the first argument.

local RS = game.ReplicatedStorage
local function pos(player, loc)
print(loc)
	
	
end
RS.Pos.OnServerEvent:Connect(pos)

Yeah, I figured out what I did wrong, I apologize.

The first argument when you firing a RemoteEvent is the Player, so you need to put it in the parameters like:

local RS = game.ReplicatedStorage
local function pos(player, loc)
print(loc)
	
	
end
RS.Pos.OnServerEvent:Connect(pos)
1 Like

It still doesnt work


(yes I changed the script it’s just it gave the same results)

The player is the first argument, so it is printing the player. Make a second argument as we both showed above.

Because you messed with the Local Script.

The Local Script was perfectly fine.

Local Script

local player = game.Players.LocalPlayer
local parts = workspace.Union
local RS = game.ReplicatedStorage
local mouse = player:GetMouse()
mouse.Button1Down:Connect(function()
	local loc = mouse.Hit.Position
	RS.Pos:FireServer(loc)

	
end)

We meant the server receives the player as the first argument. Not that you had to send it as the first.

1 Like

Oh thanks! I goofed. Glad you were here to help me. :smile: