Placement System not placing in the actual area I select

You can write your topic however you want, but you need to answer these questions:

  1. Place blocks/items within a users plot for it to save & restore back to any plot selected.
  2. It places it way off the plot so not sure why it’s not picking it up.
  3. Read through alot and tried a few diffrenet approaches, But not sure what else todo.

I’ve got a Gif which i’ve taken.

Here is my placeblock script etc:

--serverside script
-- Event handler for block placement
local function onPlaceEvent(player, blockName, position, rotation)
	print("onPlaceEvent triggered", player.Name, blockName, position, rotation)

	-- Retrieve the player's plot
	local plotIdentifier = playerPlots[player.UserId]
	if not plotIdentifier then
		warn("Plot identifier not found for the player: " .. player.Name)
		return
	end

	local plot = game.Workspace.Plots:FindFirstChild(plotIdentifier)
	if not plot then
		warn("Plot not found: " .. plotIdentifier)
		return
	end

	local blockFound = findBlockInGroups(ReplicatedStorage.Builder, blockName)
	if blockFound then
		-- Proceed with placement logic
	else
		warn("Block not found: ", blockName)
	end
	
	-- Find the block model to place
	local blockToPlace = findBlockInGroups(ReplicatedStorage.Builder, blockName) -- Adjust path as necessary
	if not blockToPlace then
		warn("Block not found: " .. blockName)
		return
	end
	blockToPlace = blockToPlace:Clone()

	-- Calculate the correct placement position relative to the plot
	local plotCFrame = plot.CFrame
	local worldPosition = plotCFrame:PointToWorldSpace(position) -- Convert local position to world position
	local worldRotation = CFrame.Angles(math.rad(rotation.X), math.rad(rotation.Y), math.rad(rotation.Z))

	-- Set the block's position and parent
	blockToPlace:SetPrimaryPartCFrame(CFrame.new(worldPosition) * worldRotation)
	blockToPlace.Parent = plot

	-- Ensure the block is anchored
	for _, part in pairs(blockToPlace:GetDescendants()) do
		if part:IsA("BasePart") then
			part.Anchored = true
		end
	end

	-- Optionally update the player's blocks list and perform further checks
	print("Block placed successfully:", blockName, "at", worldPosition)
end

placeEvent.OnServerEvent:Connect(onPlaceEvent)
---player gui scripts
local function handlePlaceItemButtonClick()
	print("PlaceItemButton clicked")  -- Debug message
	if selectedBlock then
		local plotName = getPlotFunction:InvokeServer()  -- Get the plot name associated with the player
		print("Plot Name:", plotName)  -- Debug message
		if plotName and previewBlock and previewBlock.PrimaryPart then
			local position = previewBlock.PrimaryPart.Position
			local rotation = previewBlock.PrimaryPart.Orientation
			print("Sending placement data to server:", selectedBlock.Name, position, rotation)  -- Debug message
			-- Fire the PlaceEvent with the necessary information
			placeEvent:FireServer(selectedBlock.Name, position, rotation)

			-- Clean up after placing the block
			previewBlock:Destroy()
			previewBlock = nil
			isPreviewing = false
			selectedBlock = nil
			placeItemButton.Visible = false
			cancelButton.Visible = false
			print("Placement data sent to server.")
		else
			warn("No plot found or preview block is invalid.")
		end
	else
		warn("No block selected for placement.")
	end
end


if placeItemButton then	
	placeItemButton.MouseButton1Click:Connect(handlePlaceItemButtonClick)
end
local function handleCancelButtonClick()
	if isPreviewing and previewBlock then
		previewBlock:Destroy()
		previewBlock = nil
		isPreviewing = false
		selectedBlock = nil
		placeItemButton.Visible = false
		cancelButton.Visible = false
	end
end

if cancelButton then
	cancelButton.MouseButton1Click:Connect(handleCancelButtonClick)
end
local function tryPlaceBlock()
	if selectedBlock and isPreviewing and previewBlock and previewBlock.PrimaryPart then
		local position = previewBlock.PrimaryPart.Position
		local rotation = previewBlock.PrimaryPart.Orientation
		placeEvent:FireServer(selectedBlock.Name, position, rotation)
		-- Clean up
		selectedBlock = nil
		previewBlock:Destroy()
		previewBlock = nil
		isPreviewing = false
		if placeItemButton then
			placeItemButton.Visible = false
		end
		if cancelButton then
			cancelButton.Visible = false
		end
	else
		warn("No block selected or no preview block available.")
	end
end

UserInputService.InputBegan:Connect(function(input, gameProcessedEvent)
	if gameProcessedEvent then return end
	if input.KeyCode == Enum.KeyCode.E and selectedBlock and isPreviewing and previewBlock and previewBlock.PrimaryPart then
		local position = previewBlock.PrimaryPart.Position -- Corrected to use PrimaryPart
		local rotation = Vector3.new(0, 0, 0) -- Adjust if you have rotation logic
		placeEvent:FireServer(selectedBlock.Name, position, rotation)
	end
end)



local placeEvent = ReplicatedStorage:WaitForChild("PlaceEvent")
local function finalizePlacement()
	if isPreviewing and previewBlock and selectedBlock then
		if previewBlock.PrimaryPart then
			local position = previewBlock.PrimaryPart.Position
			local rotation = previewBlock.PrimaryPart.Orientation -- Ensure these are not nil

			-- Debug print
			print("Attempting to place - Position:", position, "Rotation:", rotation)

			if position and rotation then
				placeEvent:FireServer(selectedBlock.Name, position, rotation)
				print("Sent to server - Position:", position, "Rotation:", rotation)
			else
				warn("Position or Rotation is nil")
			end
		else
			warn("previewBlock does not have a PrimaryPart set")
		end

		-- Cleanup
		previewBlock:Destroy()
		previewBlock = nil
		isPreviewing = false
		selectedBlock = nil

		if placeItemButton then
			placeItemButton.Visible = false
		else
			warn("placeItemButton not found")
		end

		if cancelButton then
			cancelButton.Visible = false
		else
			warn("cancelButton not found")
		end
	end
end

-- Connect this function to wherever you want to listen for the mouse movements or touch
updatePreview()