Mouse.Hit.p.X returns my username

I’m using remote events. Here’s some of the code in my local script:

local ReplicatedStorage = game:GetService("ReplicatedStorage")
local Players = game:GetService("Players")
local localPlayer = Players.LocalPlayer
local mouse = localPlayer:GetMouse()
local RemoteEvent = ReplicatedStorage.RemoteEvent

while true do
	RemoteEvent:FireServer(mouse.Hit.p.X, mouse.Hit.p.Z)

As you can see, I’m firing a remote event and passing in the x-position and z-position of Mouse.Hit. Some of the code from the server script:

local ReplicatedStorage = game:GetService("ReplicatedStorage")
local RemoteEvent = ReplicatedStorage.RemoteEvent

function func(x, z)

The values being printed are “TheCreator1944” and a number value that changes depending on the position of my mouse. Does anyone know why my username is being returned instead of the x-position of Mouse.Hit?

It’s probably because you’re using the first argument (the player argument) instead of the second argument (the variable)


I don’t think so. According to the API Reference Manual, Mouse.Hit.p is supposed to return the position. I don’t see why the name of the player would be returned.
Mouse.Hit (

As suggested above, it’s likely because your using the player argument in the OnServerEvent for your variables. You need the player argument on the server, and other arguments after it.

RemoteEvent.OnServerEvent:connect(player, func)

1 Like

Sorry. I misunderstood how RemoteEvents work. My bad.