local re = game.ReplicatedStorage.Events.RemoteEvent
local mouse = game.Players.LocalPlayer:GetMouse()
local Camera : Part = game.Players.LocalPlayer.Character:FindFirstChild("HumanoidRootPart")
mouse.Button1Up:Connect(function()
re:FireServer(Camera.Position,mouse.Hit.Position) -- this seems to be the problem
end)

this seems to be the problem “mouse.Hit.Position”

re:FireServer(Camera.Position,mouse.Hit.Position) -- the problem

ServerScript →
IF NEEDED

remoteevent.OnServerEvent:Connect(function(Plr : Player, CameraPos:Vector3,MousePos : Vector3, BlockId : number)
local RP = RaycastParams.new()
RP.FilterDescendantsInstances = {Plr.Character}
local RC = workspace:Raycast(CameraPos, MousePos, RP)
if RC then
local Touched : BasePart = RC.Instance
local Part = Instance.new("Part")
Part.Size = Vector3.new(2,2,2)
local ProperPos = RC.Position+Vector3.new(0,(Part.Size.Y/2),0)
print(Part.Size.Y/2)
local PositionX = math.round(ProperPos.X / grid) * grid
local PositionY = math.round(ProperPos.Y / grid) * grid
local PositionZ = math.round(ProperPos.Z / grid) * grid
Part.Position = Vector3.new(PositionX, PositionY, PositionZ)
Part.Anchored = true
Part.Parent = workspace
end
end)

It may be returning nil because it is firing at the incorrect place or is never reaching its target.

Firstly, for the ray’s direction, you need to subtract MousePos from CameraPos; this will get a Vector3 representing the distance between the two objects with CameraPos as the reference.

Next, you can multiply this result to ensure the ray hits its intended target. For example, you can multiply it by 2 and it should work.

The second parameter of workspace:Raycast() is a direction vector. You are using the mouse position instead of the direction the ray needs to travel to from the camera. You can calculate the direction by doing CameraPos - MousePos instead.

This gets the direction of the mouse compared to the camera. Raycast uses direction instead of plain locations. By subtracting your target position (MousePos) from your ray origin (CameraPos), it gives the direction of where the mouse is located compared to the camera.

It’s used for a grid placement system. Nvm i fixed it by literally just switching the “CameraPos - MousePos” around so its "MousePos- CameraPos ", Also who do i mark as the solution??? (You guys both had the same answer ). I have a FilterDescendantsInstances