Im trying to make item placement however there is an offset

so whenever i click, there would be an offset between where i click in the world and where it is on the screen

ok it now works, just had to add the gui inset

local insetOffset = guiservice:GetGuiInset()

UserInputService.InputBegan:Connect(function(input, process)
	if process then return end
	if input.UserInputType == Enum.UserInputType.MouseButton1 then--click to place
		
		print(input.Position)
		local pos = Vector2.new(input.Position.X, input.Position.Y) + insetOffset
		
		local clone = frame:Clone()
		clone.Parent = gui
		clone.Position = UDim2.fromOffset(pos.X, pos.Y)
		
		local ray = camera:ViewportPointToRay(pos.X, pos.Y)
		print(ray)
		
		local raycast = workspace:Raycast(ray.Origin, ray.Direction * 1000)
		print(raycast)
		placeEvent:FireServer(raycast.Position)
		return
	end
end)

it works, with either ignore gui inset on/off
however, the scary thing is that it works either way because i don’t know how it works

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.