RemoteEvent printing player name instead of mouse position

trying to position the model to the position of the mouse and it keeps printing the player’s name instead of the position of the mouse and not working because of that.

local turret = game.ServerStorage.Turret
game.ReplicatedStorage.RemoteEvent.OnServerEvent:Connect(function(pos)
	local turretclone = turret:Clone()
		for i,v in pairs (turretclone:GetChildren()) do
			if v:IsA("MeshPart") or v:IsA("Part") then
			v.Position = Vector3.new(pos)
			print(pos)
			end
		end
end)

this is the server remote listener and this is the client script

local player = game.Players.LocalPlayer
local plrmouse = player:GetMouse()

plrmouse.Button1Down:connect(function(pos)
	
    local pos = plrmouse.Hit.p
	local remoteevent = game.ReplicatedStorage.RemoteEvent
			print(pos)   	
			remoteevent:FireServer(pos)
			end)

the OnServerEvent event puts in a player as the first argument so you would have to use

game.ReplicatedStorage.RemoteEvent.OnServerEvent:Connect(function(player, pos)
	local turretclone = turret:Clone()
		for i,v in pairs (turretclone:GetChildren()) do
			if v:IsA("MeshPart") or v:IsA("Part") then
			v.Position = Vector3.new(pos)
			print(pos)
			end
		end
end)
2 Likes

Unfortunately, the Mouse events on UI elements / ClickDetectors like MouseButton1Down, MouseButton1Up, Button1Down etc. return the player who clicked the object, not the mouse, or mouse position.

Nevermind, misread. Sorry :confused: